from abc import abstractmethod
from en import parse as pattern_parse
class BaseParser(object):
@abstractmethod
def parse(self, text):
return
class PatternParser(BaseParser):
def parse(self, text):
return pattern_parse(text)
test.test.py:
import unittest
from en import parse as pattern_parse
import en.parsers as parsers
class TestPatternParser(unittest.TestCase):
def setUp(self):
self.parser = PatternParser()
self.text = "And now for something completely different."
def test_parse(self):
self.assertEqual(self.parser.parse(self.text), pattern_parse(self.text))
Apply the Inline Method refactoring to 'PatternParser.parse'
from abc import abstractmethod
from en import parse as pattern_parse
class BaseParser(object):
@abstractmethod
def parse(self, text):
return
class PatternParser(BaseParser):
pass
test.test.py:
import unittest
from en import parse as pattern_parse
import en.parsers as parsers
class TestPatternParser(unittest.TestCase):
def setUp(self):
self.parser = PatternParser()
self.text = "And now for something completely different."
def test_parse(self):
self.assertEqual(pattern_parse(self.text), pattern_parse(self.text))
The transformation changes the attribute that is passed to the original function.
The result is: self.assertEqual(pattern_parse(0self.parser.text), pattern_parse(self.text))
Causing test fail
Inline method refactoring passes the wrong parameter to the inlined function body
Steps to reproduce the behavior:
structure
en.__init.py__:
en.parsers.py:
test.test.py:
Apply the Inline Method refactoring to 'PatternParser.parse'
Expected code after refactoring:
en.__init.py__:
en.parsers.py:
test.test.py:
The transformation changes the attribute that is passed to the original function. The result is: self.assertEqual(pattern_parse(0self.parser.text), pattern_parse(self.text)) Causing test fail