Skip to content

Conversation

@sturmianseq
Copy link

This PR aims to improve test reliability of test test_give_json by removing state pollution of containers by making a deepcopy.

The test can fail in this way by running pip3 install pytest-repeat; python3 -m pytest --count=2 tests/test_dockerprettyps.py::TestDockerPrettyPs::test_give_json:

    def test_give_json(self):
        """
        Tests the dockerprettyps.give_json() method, making sure we output the same data we would normally, but in JSON.
    
        """
        containers = copy.copy(test_ps_data.ps_containers)
>       the_json = dockerprettyps.give_json(containers, CliArgs())

tests/test_dockerprettyps.py:348: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def give_json(containers, args):
        ...
        clean_date_containers = _json_container_dates(containers)
        more_cleaned = []
        for container in clean_date_containers:
>           more_cleaned.append(container.pop('color'))
E           KeyError: 'color'

It may be better to clean state pollutions so that some other tests won't fail in the future due to the shared state pollution.

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 this pull request may close these issues.

1 participant