Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove_class fix breaks code when there are decorators on methods #49

Open
Code0x58 opened this issue Nov 28, 2020 · 0 comments
Open

remove_class fix breaks code when there are decorators on methods #49

Code0x58 opened this issue Nov 28, 2020 · 0 comments

Comments

@Code0x58
Copy link
Contributor

Code0x58 commented Nov 28, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant