summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-01-19 14:29:34 +0000
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-01-19 14:29:34 +0000
commitdd8231cfe716bd691fa8d0caa82e2f94737318c4 (patch)
tree4b8f7af0b924827251b41baaadf5b40f88d37a3a
parent96143d48f432d08be650ea69cbd56cb50988e855 (diff)
downloadmorph-dd8231cfe716bd691fa8d0caa82e2f94737318c4.tar.gz
Get rid of assertIn, assertNotIn that are only available in Python 2.7.
-rw-r--r--morphlib/blobs_tests.py50
-rw-r--r--morphlib/stopwatch_tests.py16
2 files changed, 33 insertions, 33 deletions
diff --git a/morphlib/blobs_tests.py b/morphlib/blobs_tests.py
index 75d58d46..c012206a 100644
--- a/morphlib/blobs_tests.py
+++ b/morphlib/blobs_tests.py
@@ -29,23 +29,23 @@ class BlobsTests(unittest.TestCase):
self.assertEqual(len(blob1.parents), 0)
blob1.add_parent(blob2)
- self.assertIn(blob2, blob1.parents)
- self.assertNotIn(blob3, blob1.parents)
+ self.assertTrue(blob2 in blob1.parents)
+ self.assertTrue(blob3 not in blob1.parents)
self.assertEqual(len(blob1.parents), 1)
blob1.add_parent(blob3)
- self.assertIn(blob2, blob1.parents)
- self.assertIn(blob3, blob1.parents)
+ self.assertTrue(blob2 in blob1.parents)
+ self.assertTrue(blob3 in blob1.parents)
self.assertEqual(len(blob1.parents), 2)
blob1.remove_parent(blob2)
- self.assertNotIn(blob2, blob1.parents)
- self.assertIn(blob3, blob1.parents)
+ self.assertTrue(blob2 not in blob1.parents)
+ self.assertTrue(blob3 in blob1.parents)
self.assertEqual(len(blob1.parents), 1)
blob1.remove_parent(blob3)
- self.assertNotIn(blob2, blob1.parents)
- self.assertNotIn(blob3, blob1.parents)
+ self.assertTrue(blob2 not in blob1.parents)
+ self.assertTrue(blob3 not in blob1.parents)
self.assertEqual(len(blob1.parents), 0)
def test_blob_add_remove_dependency(self):
@@ -57,37 +57,37 @@ class BlobsTests(unittest.TestCase):
blob1.add_dependency(blob2)
- self.assertIn(blob2, blob1.dependencies)
- self.assertIn(blob1, blob2.dependents)
+ self.assertTrue(blob2 in blob1.dependencies)
+ self.assertTrue(blob1 in blob2.dependents)
self.assertTrue(blob1.depends_on(blob2))
blob2.add_dependency(blob1)
- self.assertIn(blob2, blob1.dependencies)
- self.assertIn(blob1, blob2.dependents)
- self.assertIn(blob1, blob2.dependencies)
- self.assertIn(blob2, blob1.dependents)
+ self.assertTrue(blob2 in blob1.dependencies)
+ self.assertTrue(blob1 in blob2.dependents)
+ self.assertTrue(blob1 in blob2.dependencies)
+ self.assertTrue(blob2 in blob1.dependents)
self.assertTrue(blob1.depends_on(blob2))
self.assertTrue(blob2.depends_on(blob1))
blob1.remove_dependency(blob2)
- self.assertNotIn(blob2, blob1.dependencies)
- self.assertNotIn(blob1, blob2.dependents)
- self.assertIn(blob1, blob2.dependencies)
- self.assertIn(blob2, blob1.dependents)
+ self.assertTrue(blob2 not in blob1.dependencies)
+ self.assertTrue(blob1 not in blob2.dependents)
+ self.assertTrue(blob1 in blob2.dependencies)
+ self.assertTrue(blob2 in blob1.dependents)
self.assertFalse(blob1.depends_on(blob2))
self.assertTrue(blob2.depends_on(blob1))
blob2.remove_dependency(blob1)
- self.assertNotIn(blob2, blob1.dependencies)
- self.assertNotIn(blob1, blob2.dependents)
- self.assertNotIn(blob1, blob2.dependencies)
- self.assertNotIn(blob2, blob1.dependents)
+ self.assertTrue(blob2 not in blob1.dependencies)
+ self.assertTrue(blob1 not in blob2.dependents)
+ self.assertTrue(blob1 not in blob2.dependencies)
+ self.assertTrue(blob2 not in blob1.dependents)
self.assertFalse(blob1.depends_on(blob2))
self.assertFalse(blob2.depends_on(blob1))
@@ -100,15 +100,15 @@ class BlobsTests(unittest.TestCase):
stratum_morph = loader.load('repo', 'ref', 'foo.morph')
stratum = morphlib.blobs.Stratum(stratum_morph)
self.assertEquals(len(stratum.chunks), 1)
- self.assertIn('foo', stratum.chunks)
+ self.assertTrue('foo' in stratum.chunks)
self.assertEqual(['.'], stratum.chunks['foo'])
chunk_morph = loader.load('repo', 'ref', 'bar.morph')
chunk = morphlib.blobs.Chunk(chunk_morph)
self.assertEqual(len(chunk.chunks), 2)
- self.assertIn('include', chunk.chunks)
+ self.assertTrue('include' in chunk.chunks)
self.assertEqual(chunk.chunks['include'], ['include/'])
- self.assertIn('src', chunk.chunks)
+ self.assertTrue('src' in chunk.chunks)
self.assertEqual(chunk.chunks['src'], ['src/'])
def get_morph_text(self, repo, ref, filename):
diff --git a/morphlib/stopwatch_tests.py b/morphlib/stopwatch_tests.py
index 58a18a36..0d4d98d9 100644
--- a/morphlib/stopwatch_tests.py
+++ b/morphlib/stopwatch_tests.py
@@ -32,7 +32,7 @@ class StopwatchTests(unittest.TestCase):
self.stopwatch.tick('tick', 'a')
self.assertTrue(self.stopwatch.times('tick'))
self.assertTrue(self.stopwatch.time('tick', 'a'))
- self.assertIn('a', self.stopwatch.times('tick'))
+ self.assertTrue('a' in self.stopwatch.times('tick'))
self.assertEqual(self.stopwatch.time('tick', 'a'),
self.stopwatch.times('tick')['a'])
@@ -60,16 +60,16 @@ class StopwatchTests(unittest.TestCase):
def test_with(self):
with self.stopwatch('foo'):
pass
- self.assert_(self.stopwatch.start_stop_seconds('foo') < 1.0)
+ self.assertTrue(self.stopwatch.start_stop_seconds('foo') < 1.0)
def test_with_within_with(self):
with self.stopwatch('foo'):
with self.stopwatch('bar'):
pass
- self.assert_(self.stopwatch.start_time('foo'))
- self.assert_(self.stopwatch.stop_time('foo'))
- self.assert_(self.stopwatch.start_time('bar'))
- self.assert_(self.stopwatch.stop_time('bar'))
- self.assert_(self.stopwatch.start_stop_seconds('foo') < 1.0)
- self.assert_(self.stopwatch.start_stop_seconds('bar') < 1.0)
+ self.assertTrue(self.stopwatch.start_time('foo') is not None)
+ self.assertTrue(self.stopwatch.stop_time('foo') is not None)
+ self.assertTrue(self.stopwatch.start_time('bar') is not None)
+ self.assertTrue(self.stopwatch.stop_time('bar') is not None)
+ self.assertTrue(self.stopwatch.start_stop_seconds('foo') < 1.0)
+ self.assertTrue(self.stopwatch.start_stop_seconds('bar') < 1.0)