1- import pytest
1+ import unittest
22import json
33import io
44from 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