minimindslab-env-file-diff 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- minimindslab_env_file_diff-0.1.0/LICENSE +21 -0
- minimindslab_env_file_diff-0.1.0/PKG-INFO +64 -0
- minimindslab_env_file_diff-0.1.0/README.md +53 -0
- minimindslab_env_file_diff-0.1.0/pyproject.toml +22 -0
- minimindslab_env_file_diff-0.1.0/setup.cfg +4 -0
- minimindslab_env_file_diff-0.1.0/src/minimindslab_env_file_diff/__init__.py +10 -0
- minimindslab_env_file_diff-0.1.0/src/minimindslab_env_file_diff/__main__.py +33 -0
- minimindslab_env_file_diff-0.1.0/src/minimindslab_env_file_diff/core.py +110 -0
- minimindslab_env_file_diff-0.1.0/src/minimindslab_env_file_diff.egg-info/PKG-INFO +64 -0
- minimindslab_env_file_diff-0.1.0/src/minimindslab_env_file_diff.egg-info/SOURCES.txt +12 -0
- minimindslab_env_file_diff-0.1.0/src/minimindslab_env_file_diff.egg-info/dependency_links.txt +1 -0
- minimindslab_env_file_diff-0.1.0/src/minimindslab_env_file_diff.egg-info/entry_points.txt +2 -0
- minimindslab_env_file_diff-0.1.0/src/minimindslab_env_file_diff.egg-info/top_level.txt +1 -0
- minimindslab_env_file_diff-0.1.0/tests/test_env_diff.py +72 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MiniMindsLab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: minimindslab-env-file-diff
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Deterministically compare two .env-style files and report added, removed, changed, and ignored keys with stable ordering.
|
|
5
|
+
Author: MiniMindsLab
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# MiniMindsLab Env File Diff
|
|
13
|
+
|
|
14
|
+
Deterministically compare two `.env`-style files and report:
|
|
15
|
+
|
|
16
|
+
- Added keys
|
|
17
|
+
- Removed keys
|
|
18
|
+
- Changed keys
|
|
19
|
+
- Ignored lines (comments/blank/invalid)
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- Stable ordering (sorted keys in output)
|
|
24
|
+
- Whitespace-tolerant parsing
|
|
25
|
+
- `#` comments and blank lines are ignored
|
|
26
|
+
- Duplicate keys resolve by **last occurrence wins**
|
|
27
|
+
- Pure Python standard library only
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install minimindslab-env-file-diff
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## CLI Usage
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
miniminds-env-diff path/to/old.env path/to/new.env
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Example output:
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
ADDED (1)
|
|
45
|
+
+ NEW_KEY=new
|
|
46
|
+
REMOVED (1)
|
|
47
|
+
- OLD_KEY=old
|
|
48
|
+
CHANGED (1)
|
|
49
|
+
~ SHARED_KEY: before -> after
|
|
50
|
+
IGNORED
|
|
51
|
+
old.env: comments=1 blanks=1 invalid=0
|
|
52
|
+
new.env: comments=0 blanks=2 invalid=1
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Library Usage
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from minimindslab_env_file_diff import compare_env_files
|
|
59
|
+
|
|
60
|
+
result = compare_env_files("old.env", "new.env")
|
|
61
|
+
print(result["added"])
|
|
62
|
+
print(result["removed"])
|
|
63
|
+
print(result["changed"])
|
|
64
|
+
```
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# MiniMindsLab Env File Diff
|
|
2
|
+
|
|
3
|
+
Deterministically compare two `.env`-style files and report:
|
|
4
|
+
|
|
5
|
+
- Added keys
|
|
6
|
+
- Removed keys
|
|
7
|
+
- Changed keys
|
|
8
|
+
- Ignored lines (comments/blank/invalid)
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- Stable ordering (sorted keys in output)
|
|
13
|
+
- Whitespace-tolerant parsing
|
|
14
|
+
- `#` comments and blank lines are ignored
|
|
15
|
+
- Duplicate keys resolve by **last occurrence wins**
|
|
16
|
+
- Pure Python standard library only
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install minimindslab-env-file-diff
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## CLI Usage
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
miniminds-env-diff path/to/old.env path/to/new.env
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Example output:
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
ADDED (1)
|
|
34
|
+
+ NEW_KEY=new
|
|
35
|
+
REMOVED (1)
|
|
36
|
+
- OLD_KEY=old
|
|
37
|
+
CHANGED (1)
|
|
38
|
+
~ SHARED_KEY: before -> after
|
|
39
|
+
IGNORED
|
|
40
|
+
old.env: comments=1 blanks=1 invalid=0
|
|
41
|
+
new.env: comments=0 blanks=2 invalid=1
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Library Usage
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from minimindslab_env_file_diff import compare_env_files
|
|
48
|
+
|
|
49
|
+
result = compare_env_files("old.env", "new.env")
|
|
50
|
+
print(result["added"])
|
|
51
|
+
print(result["removed"])
|
|
52
|
+
print(result["changed"])
|
|
53
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77.0.3"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "minimindslab-env-file-diff"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Deterministically compare two .env-style files and report added, removed, changed, and ignored keys with stable ordering."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "MiniMindsLab" }]
|
|
13
|
+
dependencies = []
|
|
14
|
+
|
|
15
|
+
[project.scripts]
|
|
16
|
+
miniminds-env-diff = "minimindslab_env_file_diff.__main__:main"
|
|
17
|
+
|
|
18
|
+
[tool.setuptools]
|
|
19
|
+
package-dir = {"" = "src"}
|
|
20
|
+
|
|
21
|
+
[tool.setuptools.packages.find]
|
|
22
|
+
where = ["src"]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from .core import compare_env_files, render_report
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def main(argv: list[str] | None = None) -> int:
|
|
11
|
+
parser = argparse.ArgumentParser(
|
|
12
|
+
prog="miniminds-env-diff",
|
|
13
|
+
description="Deterministically compare two .env-style files.",
|
|
14
|
+
)
|
|
15
|
+
parser.add_argument("old_file")
|
|
16
|
+
parser.add_argument("new_file")
|
|
17
|
+
args = parser.parse_args(argv)
|
|
18
|
+
|
|
19
|
+
old_label = Path(args.old_file).name
|
|
20
|
+
new_label = Path(args.new_file).name
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
diff = compare_env_files(args.old_file, args.new_file)
|
|
24
|
+
except FileNotFoundError as exc:
|
|
25
|
+
print(str(exc), file=sys.stderr)
|
|
26
|
+
return 2
|
|
27
|
+
|
|
28
|
+
print(render_report(diff, old_label, new_label))
|
|
29
|
+
return 0
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
if __name__ == "__main__":
|
|
33
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Dict, Tuple
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True)
|
|
9
|
+
class ParseStats:
|
|
10
|
+
comments: int
|
|
11
|
+
blanks: int
|
|
12
|
+
invalid: int
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def parse_env_file(path: str | Path) -> Tuple[Dict[str, str], ParseStats]:
|
|
16
|
+
p = Path(path)
|
|
17
|
+
if not p.exists() or not p.is_file():
|
|
18
|
+
raise FileNotFoundError(f"File not found: {p}")
|
|
19
|
+
|
|
20
|
+
mapping: Dict[str, str] = {}
|
|
21
|
+
comments = 0
|
|
22
|
+
blanks = 0
|
|
23
|
+
invalid = 0
|
|
24
|
+
|
|
25
|
+
with p.open("r", encoding="utf-8") as f:
|
|
26
|
+
for raw in f:
|
|
27
|
+
line = raw.strip()
|
|
28
|
+
if not line:
|
|
29
|
+
blanks += 1
|
|
30
|
+
continue
|
|
31
|
+
if line.startswith("#"):
|
|
32
|
+
comments += 1
|
|
33
|
+
continue
|
|
34
|
+
if "=" not in line:
|
|
35
|
+
invalid += 1
|
|
36
|
+
continue
|
|
37
|
+
key, value = line.split("=", 1)
|
|
38
|
+
key = key.strip()
|
|
39
|
+
value = value.strip()
|
|
40
|
+
if not key:
|
|
41
|
+
invalid += 1
|
|
42
|
+
continue
|
|
43
|
+
mapping[key] = value
|
|
44
|
+
|
|
45
|
+
return mapping, ParseStats(comments=comments, blanks=blanks, invalid=invalid)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def compare_env_mappings(old: Dict[str, str], new: Dict[str, str]) -> dict:
|
|
49
|
+
old_keys = set(old)
|
|
50
|
+
new_keys = set(new)
|
|
51
|
+
|
|
52
|
+
added_keys = sorted(new_keys - old_keys)
|
|
53
|
+
removed_keys = sorted(old_keys - new_keys)
|
|
54
|
+
common = sorted(old_keys & new_keys)
|
|
55
|
+
changed_keys = [k for k in common if old[k] != new[k]]
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
"added": {k: new[k] for k in added_keys},
|
|
59
|
+
"removed": {k: old[k] for k in removed_keys},
|
|
60
|
+
"changed": {k: {"old": old[k], "new": new[k]} for k in changed_keys},
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def compare_env_files(old_path: str | Path, new_path: str | Path) -> dict:
|
|
65
|
+
old_map, old_stats = parse_env_file(old_path)
|
|
66
|
+
new_map, new_stats = parse_env_file(new_path)
|
|
67
|
+
diff = compare_env_mappings(old_map, new_map)
|
|
68
|
+
diff["ignored"] = {
|
|
69
|
+
str(Path(old_path).name): {
|
|
70
|
+
"comments": old_stats.comments,
|
|
71
|
+
"blanks": old_stats.blanks,
|
|
72
|
+
"invalid": old_stats.invalid,
|
|
73
|
+
},
|
|
74
|
+
str(Path(new_path).name): {
|
|
75
|
+
"comments": new_stats.comments,
|
|
76
|
+
"blanks": new_stats.blanks,
|
|
77
|
+
"invalid": new_stats.invalid,
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
return diff
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def render_report(diff: dict, old_label: str, new_label: str) -> str:
|
|
84
|
+
lines: list[str] = []
|
|
85
|
+
|
|
86
|
+
added = diff["added"]
|
|
87
|
+
removed = diff["removed"]
|
|
88
|
+
changed = diff["changed"]
|
|
89
|
+
|
|
90
|
+
lines.append(f"ADDED ({len(added)})")
|
|
91
|
+
for k in sorted(added):
|
|
92
|
+
lines.append(f" + {k}={added[k]}")
|
|
93
|
+
|
|
94
|
+
lines.append(f"REMOVED ({len(removed)})")
|
|
95
|
+
for k in sorted(removed):
|
|
96
|
+
lines.append(f" - {k}={removed[k]}")
|
|
97
|
+
|
|
98
|
+
lines.append(f"CHANGED ({len(changed)})")
|
|
99
|
+
for k in sorted(changed):
|
|
100
|
+
lines.append(f" ~ {k}: {changed[k]['old']} -> {changed[k]['new']}")
|
|
101
|
+
|
|
102
|
+
ignored = diff.get("ignored", {})
|
|
103
|
+
lines.append("IGNORED")
|
|
104
|
+
for label in (old_label, new_label):
|
|
105
|
+
stats = ignored.get(label, {"comments": 0, "blanks": 0, "invalid": 0})
|
|
106
|
+
lines.append(
|
|
107
|
+
f" {label}: comments={stats['comments']} blanks={stats['blanks']} invalid={stats['invalid']}"
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
return "\n".join(lines)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: minimindslab-env-file-diff
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Deterministically compare two .env-style files and report added, removed, changed, and ignored keys with stable ordering.
|
|
5
|
+
Author: MiniMindsLab
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# MiniMindsLab Env File Diff
|
|
13
|
+
|
|
14
|
+
Deterministically compare two `.env`-style files and report:
|
|
15
|
+
|
|
16
|
+
- Added keys
|
|
17
|
+
- Removed keys
|
|
18
|
+
- Changed keys
|
|
19
|
+
- Ignored lines (comments/blank/invalid)
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- Stable ordering (sorted keys in output)
|
|
24
|
+
- Whitespace-tolerant parsing
|
|
25
|
+
- `#` comments and blank lines are ignored
|
|
26
|
+
- Duplicate keys resolve by **last occurrence wins**
|
|
27
|
+
- Pure Python standard library only
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install minimindslab-env-file-diff
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## CLI Usage
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
miniminds-env-diff path/to/old.env path/to/new.env
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Example output:
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
ADDED (1)
|
|
45
|
+
+ NEW_KEY=new
|
|
46
|
+
REMOVED (1)
|
|
47
|
+
- OLD_KEY=old
|
|
48
|
+
CHANGED (1)
|
|
49
|
+
~ SHARED_KEY: before -> after
|
|
50
|
+
IGNORED
|
|
51
|
+
old.env: comments=1 blanks=1 invalid=0
|
|
52
|
+
new.env: comments=0 blanks=2 invalid=1
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Library Usage
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from minimindslab_env_file_diff import compare_env_files
|
|
59
|
+
|
|
60
|
+
result = compare_env_files("old.env", "new.env")
|
|
61
|
+
print(result["added"])
|
|
62
|
+
print(result["removed"])
|
|
63
|
+
print(result["changed"])
|
|
64
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/minimindslab_env_file_diff/__init__.py
|
|
5
|
+
src/minimindslab_env_file_diff/__main__.py
|
|
6
|
+
src/minimindslab_env_file_diff/core.py
|
|
7
|
+
src/minimindslab_env_file_diff.egg-info/PKG-INFO
|
|
8
|
+
src/minimindslab_env_file_diff.egg-info/SOURCES.txt
|
|
9
|
+
src/minimindslab_env_file_diff.egg-info/dependency_links.txt
|
|
10
|
+
src/minimindslab_env_file_diff.egg-info/entry_points.txt
|
|
11
|
+
src/minimindslab_env_file_diff.egg-info/top_level.txt
|
|
12
|
+
tests/test_env_diff.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
minimindslab_env_file_diff
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import contextlib
|
|
2
|
+
import io
|
|
3
|
+
import tempfile
|
|
4
|
+
import unittest
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from minimindslab_env_file_diff import __main__ as cli_main
|
|
8
|
+
from minimindslab_env_file_diff.core import compare_env_files, parse_env_file
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class EnvDiffTests(unittest.TestCase):
|
|
12
|
+
def test_acceptance_sorted_added_removed_changed(self):
|
|
13
|
+
with tempfile.TemporaryDirectory() as td:
|
|
14
|
+
old_p = Path(td) / "old.env"
|
|
15
|
+
new_p = Path(td) / "new.env"
|
|
16
|
+
old_p.write_text("A=1\nB=2\nC=3\n", encoding="utf-8")
|
|
17
|
+
new_p.write_text("B=2\nC=30\nD=4\n", encoding="utf-8")
|
|
18
|
+
|
|
19
|
+
diff = compare_env_files(old_p, new_p)
|
|
20
|
+
self.assertEqual(list(diff["added"].keys()), ["D"])
|
|
21
|
+
self.assertEqual(list(diff["removed"].keys()), ["A"])
|
|
22
|
+
self.assertEqual(list(diff["changed"].keys()), ["C"])
|
|
23
|
+
|
|
24
|
+
def test_acceptance_ignore_comments_blanks_whitespace(self):
|
|
25
|
+
with tempfile.TemporaryDirectory() as td:
|
|
26
|
+
p = Path(td) / "a.env"
|
|
27
|
+
p.write_text("\n # c1\n KEY = value \nINVALID\n", encoding="utf-8")
|
|
28
|
+
mapping, stats = parse_env_file(p)
|
|
29
|
+
self.assertEqual(mapping, {"KEY": "value"})
|
|
30
|
+
self.assertEqual(stats.comments, 1)
|
|
31
|
+
self.assertEqual(stats.blanks, 1)
|
|
32
|
+
self.assertEqual(stats.invalid, 1)
|
|
33
|
+
|
|
34
|
+
def test_acceptance_duplicate_key_last_wins(self):
|
|
35
|
+
with tempfile.TemporaryDirectory() as td:
|
|
36
|
+
p = Path(td) / "dup.env"
|
|
37
|
+
p.write_text("X=1\nX=2\nX=3\n", encoding="utf-8")
|
|
38
|
+
mapping, _ = parse_env_file(p)
|
|
39
|
+
self.assertEqual(mapping["X"], "3")
|
|
40
|
+
|
|
41
|
+
def test_cli_stable_output_and_exit_zero(self):
|
|
42
|
+
with tempfile.TemporaryDirectory() as td:
|
|
43
|
+
old_p = Path(td) / "old.env"
|
|
44
|
+
new_p = Path(td) / "new.env"
|
|
45
|
+
old_p.write_text("A=1\n#x\n\n", encoding="utf-8")
|
|
46
|
+
new_p.write_text("A=2\nB=3\n", encoding="utf-8")
|
|
47
|
+
|
|
48
|
+
out1 = io.StringIO()
|
|
49
|
+
out2 = io.StringIO()
|
|
50
|
+
|
|
51
|
+
with contextlib.redirect_stdout(out1):
|
|
52
|
+
code1 = cli_main.main([str(old_p), str(new_p)])
|
|
53
|
+
with contextlib.redirect_stdout(out2):
|
|
54
|
+
code2 = cli_main.main([str(old_p), str(new_p)])
|
|
55
|
+
|
|
56
|
+
self.assertEqual(code1, 0)
|
|
57
|
+
self.assertEqual(code2, 0)
|
|
58
|
+
self.assertEqual(out1.getvalue(), out2.getvalue())
|
|
59
|
+
self.assertIn("ADDED (1)", out1.getvalue())
|
|
60
|
+
self.assertIn("CHANGED (1)", out1.getvalue())
|
|
61
|
+
|
|
62
|
+
def test_negative_missing_file(self):
|
|
63
|
+
with tempfile.TemporaryDirectory() as td:
|
|
64
|
+
old_p = Path(td) / "missing.env"
|
|
65
|
+
new_p = Path(td) / "new.env"
|
|
66
|
+
new_p.write_text("A=1\n", encoding="utf-8")
|
|
67
|
+
with self.assertRaises(FileNotFoundError):
|
|
68
|
+
compare_env_files(old_p, new_p)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
unittest.main()
|