File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed
Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -360,6 +360,10 @@ def is_unquoted(arg):
360360 def __str__ (self ) -> str :
361361 return self .querystring .__str__ ()
362362
363+ def __repr__ (self ) -> str :
364+ _id = self .id if isinstance (self .id , int ) else None
365+ return f"<{ self .__class__ .__name__ } : { _id } >"
366+
363367 ###########################################################################
364368 # Classmethods
365369
Original file line number Diff line number Diff line change 1+ from ..base import DBTestCase
2+ from ..example_project .tables import Manager
3+
4+
5+ class TestTableRepr (DBTestCase ):
6+ def test_repr (self ):
7+ self .assertEqual (Manager ().__repr__ (), "<Manager: None>" )
8+
9+ self .insert_row ()
10+ manager = Manager .objects ().first ().run_sync ()
11+ self .assertEqual (manager .__repr__ (), f"<Manager: { manager .id } >" )
Original file line number Diff line number Diff line change 44
55
66class TestTableStr (TestCase ):
7- def test_table_exists (self ):
7+ def test_str (self ):
88 self .assertEqual (
99 Manager ._table_str (),
1010 (
You can’t perform that action at this time.
0 commit comments