pytransitions / transitions

A lightweight, object-oriented finite state machine implementation in Python with many extensions
MIT License
5.5k stars 525 forks source link

test_codestyle.py: AssertionError #438

Closed Bridouz closed 4 years ago

Bridouz commented 4 years ago

Packaging latest version for my distro (Alpine):

_______________________ TestCodeFormat.test_conformance ________________________

self = <tests.test_codestyle.TestCodeFormat testMethod=test_conformance>

    def test_conformance(self):
        """Test that we conform to PEP-8."""
        style = pycodestyle.StyleGuide(quiet=False, ignore=['E501', 'W605'])
        if exists('transitions'):  # when run from root directory (e.g. tox)
            style.input_dir('transitions')
            style.input_dir('tests')
        else:  # when run from test directory (e.g. pycharm)
            style.input_dir('../transitions')
            style.input_dir('.')
        result = style.check_files()
>       self.assertEqual(result.total_errors, 0,
                         "Found code style errors (and warnings).")
E       AssertionError: 1 != 0 : Found code style errors (and warnings).

tests/test_codestyle.py:17: AssertionError
aleneum commented 4 years ago

Hi @Bridouz,

could you add the whole test log. I guess the actual error is mentioned a bit above.

Bridouz commented 4 years ago

Here you go.

https://gitlab.alpinelinux.org/Bridouz/aports/-/jobs/119395/raw

aleneum commented 4 years ago

Hmmm, that triggered another issue, doesn't it

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <transitions.extensions.diagrams_graphviz.Graph object at 0x7fc51d989df0>
title = 'State Machine', roi_state = None

    def generate(self, title=None, roi_state=None):
        """ Generate a DOT graph with graphviz
        Args:
            roi_state (str): Optional, show only custom states and edges from roi_state
        """
        if not pgv:  # pragma: no cover
>           raise Exception('AGraph diagram requires graphviz')
E           Exception: AGraph diagram requires graphviz

transitions/extensions/diagrams_graphviz.py:77: Exception
=========================== short test summary info ============================
FAILED tests/test_async.py::AsyncGraphMachine::test___getattr___and_identify_callback
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
========================= 1 failed, 67 passed in 1.51s =========================
aleneum commented 4 years ago

So, one problem is that your process does not install optional dependencies mentioned in requirements_diagrams.txt or extras_require in setup.py. requirements_test.txt mentions the graphviz module but this module does not work when Graphviz hasn't been installed independently. I will adjust the tests to skip all tests involving (py)graphviz when this is not present. However, you might want to consider to install optional pygraphviz or Graphviz for graphviz to also test transitions diagram capabilities as done for travis or tox. I do not explicitely install Graphviz in the Travis job. I guess that's part of their image...

Bridouz commented 4 years ago

Thanks, issue solved.