unittest2pytest
unittest2pytest copied to clipboard
remove_class fix breaks code when there are decorators on methods
test patch
diff --git a/tests/fixtures/remove_class/assertEqual_in.py b/tests/fixtures/remove_class/assertEqual_in.py
index a84867b..2635814 100644
--- a/tests/fixtures/remove_class/assertEqual_in.py
+++ b/tests/fixtures/remove_class/assertEqual_in.py
@@ -7,3 +7,7 @@ class TestAssertNotEqual(TestCase):
def test_you(self):
self.assertNotEqual(abc, 'xxx')
+
+ @property
+ def test_me(self):
+ pass
diff --git a/tests/fixtures/remove_class/assertEqual_out.py b/tests/fixtures/remove_class/assertEqual_out.py
index 833d980..4da9970 100644
--- a/tests/fixtures/remove_class/assertEqual_out.py
+++ b/tests/fixtures/remove_class/assertEqual_out.py
@@ -5,3 +5,7 @@ def test_you(self):
def test_you(self):
self.assertNotEqual(abc, 'xxx')
+
+@property
+def test_me(self):
+ pass
Example test failure:
--- expected
+++ refactured result
@@ -6,6 +6,6 @@
def test_you(self):
self.assertNotEqual(abc, 'xxx')
-@property
-def test_me(self):
+ @property
+deftest_me(self):
pass
This obliterates the code in the from the point of the decorator until the end of the file.
To avoid this, you can add --nofix=remove_class
to your unittest2pytest invocation when running on files which would break.