diff options
author | David Malcolm <dmalcolm@redhat.com> | 2010-02-02 19:30:07 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2010-02-02 19:30:07 -0500 |
commit | 98f387056959d6ab8554a2fd616d1639739c4735 (patch) | |
tree | a2c8fbab663a4489895e968f191500a509bed4c4 | |
parent | 45b84e4a298d5beea5c9e12093ce4d90c980c7f1 (diff) | |
download | 2to3c-98f387056959d6ab8554a2fd616d1639739c4735.tar.gz 2to3c-98f387056959d6ab8554a2fd616d1639739c4735.tar.xz 2to3c-98f387056959d6ab8554a2fd616d1639739c4735.zip |
port typeobject.TestFixups to FixText API; add a test case to ensure it can deal with comments
-rw-r--r-- | fixes/typeobject.py | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/fixes/typeobject.py b/fixes/typeobject.py index 5615430..dde1f74 100644 --- a/fixes/typeobject.py +++ b/fixes/typeobject.py @@ -35,26 +35,43 @@ def fixup_typeobject_initializers(content): else: return content -from fixes import Fix +from fixes import Fix, FixTest class FixTypeobjectInitializers(Fix): def transform(self, string): return fixup_typeobject_initializers(string) import unittest -class TestFixups(unittest.TestCase): +class TestFixups(FixTest): + def setUp(self): + self.fixer = FixTypeobjectInitializers() + def test_fixups(self): - self.assertEquals(fixup_typeobject_initializers(''' + self.assertTransformsTo(self.fixer, + ''' PyTypeObject DBusPyIntBase_Type = { PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) 0, "_dbus_bindings._IntBase", -''' - ), +''', ''' PyTypeObject DBusPyIntBase_Type = { PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) "_dbus_bindings._IntBase", -''' - ) +''') + + def test_fixup_with_comment(self): + self.assertTransformsTo(self.fixer, + ''' +PyTypeObject PyFortran_Type = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "fortran", /*tp_name*/ +''', + ''' +PyTypeObject PyFortran_Type = { + PyVarObject_HEAD_INIT(0, 0) /*ob_size*/ + "fortran", /*tp_name*/ +''') + if __name__ == '__main__': unittest.main() |