I have this class static method in python 3, with necessary test code
example.py:
class ExampleClass{
...
@staticmethod
def get_new_id: str, id: str):
return {
"new_id": "{}_{}_{}".format(
datetime.utcnow().strftime("%Y%m%d%H%M%S"),
id,
name
),
"old_id": id
}
...
}
test_example.py:
...
class TestExampleId(TestCase):
@patch("example_folder.example.datetime", Mock(utcnow=Mock(return_value=datetime(1992, 1, 26, 12, 0, 0))))
def given_id_name_example_object_returned(self):
self.assertEqual(
{
'old_id': 'xxx',
'new_id': '19920916120000_xxx_test_name'
}, ExampleClass.get_new_id("xxx", "test_name")
)
This is about it in terms of what mutations can do. But in mutmut, there is one surviving mutation, and it is the removal of @staticmethod
. So i have two questions:
- How can the test pass if the method called is from an uninstantiated class without the @staticmethod declaration?
- what additional test case is needed to prevent a mutation surviving without the @staticmethod?
Thanks.