Skip to content

Commit

Permalink
Fix bug with pytest that was unexpectedly skipping some tests
Browse files Browse the repository at this point in the history
Because of a bug with pytest, I can't simply mark TestListCommandView
with @pytest.mark.skip. I had to made it inherit from object instad of
ReadOnlyAPITests, and to manually skip the extra tests inside the class.
See https://docs.pytest.org/en/latest/skipping.html#skip-all-test-functions-of-a-class-or-module
and pytest-dev/pytest#568 for more information
  • Loading branch information
cript0nauta committed Nov 3, 2017
1 parent ac7d1cc commit a96a59c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test_cases/test_api_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@
WorkspaceFactory, ServiceFactory


@pytest.mark.skip(reason='refactor needed to adapt new m2m model')
# Note: because of a bug with pytest, I can't simply mark TestListCommandView
# with @pytest.mark.skip. I had to made it inherit from object instad of
# ReadOnlyAPITests, and to manually skip the extra tests inside the class.
# See https://docs.pytest.org/en/latest/skipping.html#skip-all-test-functions-of-a-class-or-module
# and https://github.com/pytest-dev/pytest/issues/568 for more information

@pytest.mark.usefixtures('logged_user')
class TestListCommandView(ReadOnlyAPITests):
# class TestListCommandView(ReadOnlyAPITests): # TODO: change to this!!!
class TestListCommandView(object):
model = Command
factory = factories.CommandFactory
api_endpoint = 'commands'
view_class = CommandView

@pytest.mark.skip(reason='refactor needed to adapt new m2m model')
def test_backwards_compatibility_list(self, test_client, second_workspace, session):
self.factory.create(workspace=second_workspace)
session.commit()
Expand All @@ -43,6 +50,7 @@ def test_backwards_compatibility_list(self, test_client, second_workspace, sessi
]
assert set(object_properties) == set(command['value'].keys())

@pytest.mark.skip(reason='refactor needed to adapt new m2m model')
def test_activity_feed(self, session, test_client):
command = self.factory.create()
another_command = EmptyCommandFactory.create(workspace=command.workspace)
Expand Down Expand Up @@ -76,6 +84,7 @@ def test_activity_feed(self, session, test_client):
u'sum_created_vulnerabilities_web': 0,
u'sum_created_vulnerability_critical': 0}]

@pytest.mark.skip(reason='refactor needed to adapt new m2m model')
def test_verify_created_critical_vulns_is_correctly_showing_sum_values(self, session, test_client):
workspace = WorkspaceFactory.create()
command = EmptyCommandFactory.create(workspace=workspace)
Expand Down Expand Up @@ -109,6 +118,7 @@ def test_verify_created_critical_vulns_is_correctly_showing_sum_values(self, ses
u'sum_created_vulnerability_critical': 1
}]

@pytest.mark.skip(reason='refactor needed to adapt new m2m model')
def test_verify_created_vulns_with_host_and_service_verification(self, session, test_client):
workspace = WorkspaceFactory.create()
command = EmptyCommandFactory.create(workspace=workspace)
Expand Down Expand Up @@ -148,6 +158,7 @@ def test_verify_created_vulns_with_host_and_service_verification(self, session,
u'sum_created_vulnerability_critical': 1
}]

@pytest.mark.skip(reason='refactor needed to adapt new m2m model')
def test_multiple_commands_executed_with_same_objects_found(self, session, test_client):

workspace = WorkspaceFactory.create()
Expand Down

0 comments on commit a96a59c

Please sign in to comment.