Skip to content

Commit 26dce46

Browse files
committed
Fix tests for building frames in tests.test_typedef and tests.test_term
1 parent d599e73 commit 26dce46

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

tests/common.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,41 @@
1010

1111
class _TestFrame(object):
1212

13-
type = NotImplementedError
13+
Frame = NotImplementedError
14+
NameClause = None
15+
CreatedByClause = None
1416

1517
def setUp(self):
1618
self.id = fastobo.id.PrefixedIdent("MS", "1000031")
1719

1820
def test_init(self):
1921
try:
20-
frame = self.type(self.id)
22+
frame = self.Frame(self.id)
2123
except Exception:
2224
self.fail("could not create frame instances")
2325

2426
def test_init_iterable(self):
2527
try:
26-
frame = self.type(self.id, [])
28+
frame = self.Frame(self.id, [])
2729
except Exception:
2830
self.fail("could not create frame instances")
2931
try:
30-
frame = self.type(self.id, [
31-
fastobo.term.NameClause("thing"),
32-
fastobo.term.CreatedByClause("Martin Larralde")
32+
frame = self.Frame(self.id, [
33+
self.NameClause("thing"),
34+
self.CreatedByClause("Martin Larralde")
3335
])
3436
except Exception:
3537
self.fail("could not create frame from iterable")
3638

3739
def test_init_type_error(self):
38-
self.assertRaises(TypeError, self.type, 1)
39-
self.assertRaises(TypeError, self.type, [1])
40-
self.assertRaises(TypeError, self.type, ["abc"])
41-
self.assertRaises(TypeError, self.type, "abc")
42-
self.assertRaises(TypeError, self.type, self.id, 1)
43-
self.assertRaises(TypeError, self.type, self.id, [1])
44-
self.assertRaises(TypeError, self.type, self.id, ["abc"])
45-
self.assertRaises(TypeError, self.type, self.id, "abc")
40+
self.assertRaises(TypeError, self.Frame, 1)
41+
self.assertRaises(TypeError, self.Frame, [1])
42+
self.assertRaises(TypeError, self.Frame, ["abc"])
43+
self.assertRaises(TypeError, self.Frame, "abc")
44+
self.assertRaises(TypeError, self.Frame, self.id, 1)
45+
self.assertRaises(TypeError, self.Frame, self.id, [1])
46+
self.assertRaises(TypeError, self.Frame, self.id, ["abc"])
47+
self.assertRaises(TypeError, self.Frame, self.id, "abc")
4648

4749

4850
# --- DefClause --------------------------------------------------------------
@@ -122,7 +124,7 @@ def test_eq(self):
122124

123125
# --- CreationDateClause -----------------------------------------------------
124126

125-
class _TestIsObsoleteClause(object):
127+
class _TestCreationDateClause(object):
126128

127129
type = NotImplementedError
128130

@@ -132,12 +134,12 @@ def test_date(self):
132134
self.assertEqual(str(clause), "creation_date: 2021-01-23")
133135
self.assertEqual(repr(clause), "CreationDateClause(datetime.date(2021, 1, 23))")
134136
self.assertEqual(clause.date, d1)
135-
self.assertIsInstance(clause.date, d1)
137+
self.assertIsInstance(clause.date, datetime.date)
136138
d2 = datetime.date(2021, 2, 15)
137139
clause.date = d2
138140
self.assertIsInstance(clause.date, datetime.date)
139141

140-
def test_date(self):
142+
def test_datetime(self):
141143
d1 = datetime.datetime(2021, 1, 23, 12)
142144
clause = self.type(d1)
143145
self.assertEqual(str(clause), "creation_date: 2021-01-23T12:00:00")

tests/test_term.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
_TestIsObsoleteClause,
1111
_TestDefClause,
1212
_TestConsiderClause,
13-
_TestIsObsoleteClause,
13+
_TestCreationDateClause,
1414
)
1515

1616
# --- TermFrame --------------------------------------------------------------
1717

1818
class TestTermFrame(_TestFrame, unittest.TestCase):
19-
type = fastobo.term.TermFrame
19+
Frame = fastobo.term.TermFrame
20+
NameClause = fastobo.term.NameClause
21+
CreatedByClause = fastobo.term.CreatedByClause
2022

2123

2224
# --- DefClause --------------------------------------------------------------
@@ -39,5 +41,5 @@ class TestIsObsoleteClause(_TestIsObsoleteClause, unittest.TestCase):
3941

4042
# --- CreationDateClause -----------------------------------------------------
4143

42-
class TestIsObsoleteClause(_TestIsObsoleteClause, unittest.TestCase):
44+
class TestCreationDateClause(_TestCreationDateClause, unittest.TestCase):
4345
type = fastobo.term.CreationDateClause

tests/test_typedef.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
_TestIsObsoleteClause,
1111
_TestDefClause,
1212
_TestConsiderClause,
13-
_TestIsObsoleteClause,
13+
_TestCreationDateClause,
1414
)
1515

16-
# --- TermFrame --------------------------------------------------------------
16+
# --- TypedefFrame -----------------------------------------------------------
1717

1818
class TestTypedefFrame(_TestFrame, unittest.TestCase):
19-
type = fastobo.typedef.TypedefFrame
19+
Frame = fastobo.typedef.TypedefFrame
20+
NameClause = fastobo.typedef.NameClause
21+
CreatedByClause = fastobo.typedef.CreatedByClause
2022

2123

2224
# --- DefClause --------------------------------------------------------------
@@ -39,5 +41,5 @@ class TestIsObsoleteClause(_TestIsObsoleteClause, unittest.TestCase):
3941

4042
# --- CreationDateClause -----------------------------------------------------
4143

42-
class TestIsObsoleteClause(_TestIsObsoleteClause, unittest.TestCase):
44+
class TestCreationDateClause(_TestCreationDateClause, unittest.TestCase):
4345
type = fastobo.typedef.CreationDateClause

0 commit comments

Comments
 (0)