changeset 596:837d949a4539 pytest2

added test for Type.__repr__ in test_mime
author pkumar <contactprashantat@gmail.com>
date Tue, 28 Jun 2011 19:43:06 +0530
parents 1476764d3857
children c86e1f677ebc
files MoinMoin/util/_tests/test_filesys.py MoinMoin/util/_tests/test_mime.py
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/util/_tests/test_filesys.py	Mon Jun 27 23:47:44 2011 +0530
+++ b/MoinMoin/util/_tests/test_filesys.py	Tue Jun 28 19:43:06 2011 +0530
@@ -167,6 +167,5 @@
         self.test_dest_dir = tempfile.mkdtemp('', 'temp_dir')
         with pytest.raises(OSError):
             filesys.copytree(self.test_dir, self.test_dest_dir)
-        
-        
+
 coverage_modules = ['MoinMoin.util.filesys']
--- a/MoinMoin/util/_tests/test_mime.py	Mon Jun 27 23:47:44 2011 +0530
+++ b/MoinMoin/util/_tests/test_mime.py	Tue Jun 28 19:43:06 2011 +0530
@@ -15,6 +15,9 @@
     assert t.type == 'foo'
     assert t.subtype == 'bar'
     assert t.parameters == {'foo': 'bar'}
+    result_repr = t.__repr__()
+    assert result_repr== "<Type object: type: 'foo'; subtype: 'bar'; parameters: {'foo': 'bar'}>"   
+
 
 def test_Type_init_2():
     i = 'text/plain;encoding=utf-8'
@@ -22,6 +25,8 @@
     assert t.type == 'foo'
     assert t.subtype == 'bar'
     assert t.parameters == {'encoding': 'utf-8', 'foo': 'bar'}
+    result_repr = t.__repr__()
+    assert result_repr == "<Type object: type: 'foo'; subtype: 'bar'; parameters: {'foo': 'bar', 'encoding': 'utf-8'}>"
 
 def test_Type_init_3():
     i = Type(type='foo', subtype='bar')
@@ -29,7 +34,11 @@
     assert i is not t
     assert i == t
     assert i.parameters is not t.parameters
-
+    result_repr_t = t.__repr__()
+    result_repr_i = t.__repr__()
+    assert result_repr_t == "<Type object: type: 'foo'; subtype: 'bar'; parameters: {}>"
+    assert result_repr_t == result_repr_i, ("Expected same values but got different")
+    
 def test_Type_text():
     i = '*/*'
     t = Type(i)