From 0bf39cd1daf6528cb319c77e2f7570ad258dad4a Mon Sep 17 00:00:00 2001 From: Woosung You <113555518+wyougithub@users.noreply.github.com> Date: Fri, 16 Sep 2022 08:00:03 -0400 Subject: [PATCH] to change unit test to pytest (#9) --- README.md | 2 +- pytest.ini | 2 ++ requirements-dev.txt | 2 +- tests/__init__.py | 0 tests/common_test/cve_reader_test.py | 2 +- tests/common_test/hash_collector_test.py | 2 +- tests/common_test/parallel_test.py | 2 +- tests/common_test/release_test.py | 2 +- tests/common_test/securityfocusfetcher_test.py | 2 +- tests/common_test/securityfocusparsers_test.py | 2 +- tests/common_test/securityfocusreader_test.py | 2 +- tests/common_test/storage_test.py | 2 +- tests/common_test/vcs_test.py | 2 +- tests/wordpress_test/api_parse_test.py | 2 +- tests/wordpress_test/enumerate_plugins_test.py | 2 +- tests/wordpress_test/enumerate_themes_test.py | 2 +- tests/wordpress_test/vane_import_test.py | 2 +- tests/wordpress_test/vane_version_rebuild_test.py | 2 +- 18 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 pytest.ini create mode 100644 tests/__init__.py diff --git a/README.md b/README.md index 33a708a..ef4c089 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ source bin/activate pip install -r requirements.txt pip install -r requirements-dev.txt -nosetests +python -m pytest ``` External requirements set-up: diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..5ee6477 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +testpaths = tests diff --git a/requirements-dev.txt b/requirements-dev.txt index a39c618..5116c03 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,2 @@ -nose==1.3.7 +pytest>=6.0.1 freezegun==1.2.2 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/common_test/cve_reader_test.py b/tests/common_test/cve_reader_test.py index 5028d80..b1711ab 100644 --- a/tests/common_test/cve_reader_test.py +++ b/tests/common_test/cve_reader_test.py @@ -18,7 +18,7 @@ from unittest import TestCase from unittest.mock import MagicMock, call from datetime import datetime -from fixtures import freeze_time, async_test, ClientSessionMock +from tests.fixtures import freeze_time, async_test, ClientSessionMock from aiohttp.test_utils import make_mocked_coro from openwebvulndb.common.errors import VulnerabilityNotFound diff --git a/tests/common_test/hash_collector_test.py b/tests/common_test/hash_collector_test.py index d195766..3dedab1 100644 --- a/tests/common_test/hash_collector_test.py +++ b/tests/common_test/hash_collector_test.py @@ -19,7 +19,7 @@ from unittest.mock import MagicMock, call, patch, mock_open from contextlib import contextmanager -from fixtures import async_test +from tests.fixtures import async_test from aiohttp.test_utils import make_mocked_coro from openwebvulndb.common.errors import ExecutionFailure, DirectoryExpected diff --git a/tests/common_test/parallel_test.py b/tests/common_test/parallel_test.py index 7dd3fdd..5305bd7 100644 --- a/tests/common_test/parallel_test.py +++ b/tests/common_test/parallel_test.py @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from unittest import TestCase -from fixtures import async_test +from tests.fixtures import async_test import async_timeout from aiohttp.test_utils import make_mocked_coro diff --git a/tests/common_test/release_test.py b/tests/common_test/release_test.py index a074ecc..6698374 100644 --- a/tests/common_test/release_test.py +++ b/tests/common_test/release_test.py @@ -22,7 +22,7 @@ from aiohttp import BasicAuth from aiohttp.test_utils import make_mocked_coro -from fixtures import async_test, ClientSessionMock +from tests.fixtures import async_test, ClientSessionMock from openwebvulndb.common.release import GitHubRelease diff --git a/tests/common_test/securityfocusfetcher_test.py b/tests/common_test/securityfocusfetcher_test.py index 6451987..3d0e357 100644 --- a/tests/common_test/securityfocusfetcher_test.py +++ b/tests/common_test/securityfocusfetcher_test.py @@ -17,7 +17,7 @@ import unittest from unittest.mock import MagicMock -from fixtures import file_path, async_test, ClientSessionMock +from tests.fixtures import file_path, async_test, ClientSessionMock from aiohttp.test_utils import make_mocked_coro from openwebvulndb.common.securityfocus.fetcher import SecurityFocusFetcher import asyncio diff --git a/tests/common_test/securityfocusparsers_test.py b/tests/common_test/securityfocusparsers_test.py index c5be2ca..91b8a9f 100644 --- a/tests/common_test/securityfocusparsers_test.py +++ b/tests/common_test/securityfocusparsers_test.py @@ -20,7 +20,7 @@ from datetime import datetime from openwebvulndb.common.securityfocus.parsers import InfoTabParser, ReferenceTabParser, \ DiscussionTabParser, ExploitTabParser, SolutionTabParser -from fixtures import file_path +from tests.fixtures import file_path from lxml import etree diff --git a/tests/common_test/securityfocusreader_test.py b/tests/common_test/securityfocusreader_test.py index 5c956a1..5b2d183 100644 --- a/tests/common_test/securityfocusreader_test.py +++ b/tests/common_test/securityfocusreader_test.py @@ -18,7 +18,7 @@ import unittest from unittest.mock import MagicMock from openwebvulndb.common.securityfocus.parsers import InfoTabParser, ReferenceTabParser -from fixtures import file_path, ClientSessionMock, async_test +from tests.fixtures import file_path, ClientSessionMock, async_test from openwebvulndb.common.securityfocus.reader import SecurityFocusReader from openwebvulndb.common.storage import Storage from openwebvulndb.common.manager import VulnerabilityManager diff --git a/tests/common_test/storage_test.py b/tests/common_test/storage_test.py index 8479c58..d5aba8a 100644 --- a/tests/common_test/storage_test.py +++ b/tests/common_test/storage_test.py @@ -18,7 +18,7 @@ from unittest import TestCase from unittest.mock import mock_open, patch, call, MagicMock, ANY -from fixtures import file_path +from tests.fixtures import file_path from openwebvulndb.common import Storage, Meta, VulnerabilityList, VersionList from openwebvulndb.common.schemas import VersionListSchema diff --git a/tests/common_test/vcs_test.py b/tests/common_test/vcs_test.py index bc86446..2611b5b 100644 --- a/tests/common_test/vcs_test.py +++ b/tests/common_test/vcs_test.py @@ -18,7 +18,7 @@ import asyncio from unittest import TestCase from unittest.mock import MagicMock, call, patch -from fixtures import async_test, fake_future, file_path, freeze_time +from tests.fixtures import async_test, fake_future, file_path, freeze_time from datetime import date from openwebvulndb.common import RepositoryChecker, Repository diff --git a/tests/wordpress_test/api_parse_test.py b/tests/wordpress_test/api_parse_test.py index 4bdce9b..2528975 100644 --- a/tests/wordpress_test/api_parse_test.py +++ b/tests/wordpress_test/api_parse_test.py @@ -20,7 +20,7 @@ from openwebvulndb.wordpress.errors import PluginNotFound, ThemeNotFound from openwebvulndb.common import Meta, Repository -from fixtures import read_file +from tests.fixtures import read_file class PluginApiParseTest(TestCase): diff --git a/tests/wordpress_test/enumerate_plugins_test.py b/tests/wordpress_test/enumerate_plugins_test.py index 0cc1db0..3f551b0 100644 --- a/tests/wordpress_test/enumerate_plugins_test.py +++ b/tests/wordpress_test/enumerate_plugins_test.py @@ -20,7 +20,7 @@ from unittest import TestCase from unittest.mock import MagicMock, call -from fixtures import read_file, async_test, fake_future, ClientSessionMock, ClientResponse +from tests.fixtures import read_file, async_test, fake_future, ClientSessionMock, ClientResponse from openwebvulndb.wordpress.repository import WordPressRepository, RepositoryUnreachable from openwebvulndb.wordpress.errors import PluginNotFound from openwebvulndb.common import Meta, Repository diff --git a/tests/wordpress_test/enumerate_themes_test.py b/tests/wordpress_test/enumerate_themes_test.py index 2d4f45a..50e37f8 100644 --- a/tests/wordpress_test/enumerate_themes_test.py +++ b/tests/wordpress_test/enumerate_themes_test.py @@ -20,7 +20,7 @@ from unittest import TestCase from unittest.mock import MagicMock, call -from fixtures import read_file, async_test, fake_future, ClientSessionMock, ClientResponse +from tests.fixtures import read_file, async_test, fake_future, ClientSessionMock, ClientResponse from openwebvulndb.wordpress.repository import WordPressRepository, RepositoryUnreachable from openwebvulndb.wordpress.errors import PluginNotFound from openwebvulndb.common import Meta, Repository diff --git a/tests/wordpress_test/vane_import_test.py b/tests/wordpress_test/vane_import_test.py index 53a1f6f..9f546e2 100644 --- a/tests/wordpress_test/vane_import_test.py +++ b/tests/wordpress_test/vane_import_test.py @@ -17,7 +17,7 @@ from unittest import TestCase from unittest.mock import MagicMock, mock_open, patch, call -from fixtures import file_path, freeze_time +from tests.fixtures import file_path, freeze_time from datetime import datetime, timedelta from openwebvulndb.common import VulnerabilityManager diff --git a/tests/wordpress_test/vane_version_rebuild_test.py b/tests/wordpress_test/vane_version_rebuild_test.py index 6b8e501..cd5312c 100644 --- a/tests/wordpress_test/vane_version_rebuild_test.py +++ b/tests/wordpress_test/vane_version_rebuild_test.py @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from unittest import TestCase -from fixtures import file_path +from tests.fixtures import file_path from openwebvulndb.common.models import VersionList from openwebvulndb.wordpress.vane import VaneVersionRebuild