Skip to content

Commit 1e8eb95

Browse files
author
SoundsSerious
committed
Update documentation for clarity and consistency
1 parent 33957d9 commit 1e8eb95

File tree

3 files changed

+73
-9
lines changed

3 files changed

+73
-9
lines changed

CLAUDE.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,25 @@ pip install .
1515
# Install in development mode
1616
pip install -e .
1717

18+
# Install development dependencies
19+
pip install -e ".[dev]"
20+
1821
# Test the command line tool
1922
diffgetr file1.json file2.json path.to.key
2023
```
2124

25+
## Testing Commands
26+
27+
```bash
28+
# Run unit tests
29+
python -m unittest discover tests -v
30+
31+
# Build and test package
32+
python -m build
33+
pip install dist/*.whl
34+
python -c "import diffgetr; print('Package imported successfully')"
35+
```
36+
2237
## Core Architecture
2338

2439
### Main Class: `diff_get`

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,22 @@ diff.diff_sidebyside()
203203
# - .version | "1.2.3" | "1.3.0"
204204
```
205205

206+
## Testing
207+
208+
Run the comprehensive test suite to verify functionality:
209+
210+
```bash
211+
python -m unittest discover tests -v
212+
```
213+
214+
The test suite covers:
215+
• Core diff functionality and navigation through nested structures
216+
• Multiple output formats (summary, detailed, side-by-side)
217+
• Pattern recognition for UUIDs and CSV-like data
218+
• Error handling and edge cases
219+
• IPython integration and tab completion
220+
• Command-line interface functionality
221+
206222
## Contributing
207223

208224
This tool is part of the SMART_X project ecosystem. When contributing:

tests/test_diff_get.py

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import pytest
1+
import unittest
22
import json
33
import io
44
from diffgetr.diff_get import diff_get
55

66

7-
class TestDiffGet:
7+
class TestDiffGet(unittest.TestCase):
88

99
def test_basic_diff(self):
1010
"""Test basic diff functionality"""
@@ -82,10 +82,10 @@ def test_keyerror_handling(self):
8282

8383
diff = diff_get(s0, s1)
8484

85-
with pytest.raises(KeyError) as exc_info:
85+
with self.assertRaises(KeyError) as context:
8686
diff['a']['nonexistent']
8787

88-
assert "key missing: nonexistent" in str(exc_info.value)
88+
self.assertIn("key missing: nonexistent", str(context.exception))
8989

9090
def test_string_representation(self):
9191
"""Test string representation of diff object"""
@@ -139,7 +139,7 @@ def test_diff_all_output(self):
139139

140140
def test_type_assertion(self):
141141
"""Test that different types raise assertion error"""
142-
with pytest.raises(AssertionError):
142+
with self.assertRaises(AssertionError):
143143
diff_get({"a": 1}, ["a", 1])
144144

145145
def test_ipython_key_completions(self):
@@ -154,15 +154,15 @@ def test_ipython_key_completions(self):
154154
assert isinstance(completions, list)
155155

156156

157-
class TestCLI:
157+
class TestCLI(unittest.TestCase):
158158

159159
def test_main_function_exists(self):
160160
"""Test that main function exists and is callable"""
161161
from diffgetr.diff_get import main
162-
assert callable(main)
162+
self.assertTrue(callable(main))
163163

164164

165-
class TestPatternRecognition:
165+
class TestPatternRecognition(unittest.TestCase):
166166

167167
def test_uuid_pattern_replacement(self):
168168
"""Test UUID pattern recognition in diff summary"""
@@ -175,4 +175,37 @@ def test_uuid_pattern_replacement(self):
175175
summary = output.getvalue()
176176

177177
# UUIDs should be abstracted in the summary
178-
assert "UUID" in summary or summary # At minimum should not crash
178+
assert "UUID" in summary or summary # At minimum should not crash
179+
180+
181+
if __name__ == "__main__":
182+
import sys
183+
import traceback
184+
185+
# Simple test runner
186+
test_classes = [TestDiffGet, TestCLI, TestPatternRecognition]
187+
total_tests = 0
188+
passed_tests = 0
189+
190+
for test_class in test_classes:
191+
instance = test_class()
192+
methods = [m for m in dir(instance) if m.startswith('test_')]
193+
194+
for method_name in methods:
195+
total_tests += 1
196+
try:
197+
method = getattr(instance, method_name)
198+
method()
199+
print(f"✅ {test_class.__name__}.{method_name}")
200+
passed_tests += 1
201+
except Exception as e:
202+
print(f"❌ {test_class.__name__}.{method_name}: {e}")
203+
traceback.print_exc()
204+
205+
print(f"\n🏆 SUMMARY: {passed_tests}/{total_tests} tests passed")
206+
if passed_tests == total_tests:
207+
print("✅ ALL TESTS PASSED")
208+
sys.exit(0)
209+
else:
210+
print("❌ SOME TESTS FAILED")
211+
sys.exit(1)

0 commit comments

Comments
 (0)