stratis-storage/stratis-cli

Replace inequality checks with a function

Closed this issue · 0 comments

Make a function more or less like:

def _inequality_test(self, result, expected_non_result):
    """
    :param object result: the result of a test
    :param object expected_non_result: a value which the result must not match
                                                                      but which has the expected type
    ```
    self.assertIsInstance(result, type(expected_non_result))
    self.assertNotEqual(result, expected_non_result)

then use it in every context where pairs like this occur. For example, modify:

    def test_stratisd_version(self):
        """
        Test getting the daemon version.
        """
        result = StratisDbus.stratisd_version()
        self.assertIsInstance(result, str)
        self.assertNotEqual(result, "")

so that it is instead:

    def test_stratisd_version(self):
        """
        Test getting the daemon version.
        """
        self._inequality_test(StratisDbus.stratisd_version(), "")

It should also be possible to modify test_get_managed_objects so that it uses self._inequality_test.