Skip to content

Silence errors to be raised #1145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ dependencies must already be installed (see above).
$ cd tests
$ python aggregate_tests.py

Individual tests can also be executed. Optional '-v' flags can be added to
increase log level up to DEBUG ('-vvvv').
::

$ python test_updater.py # run a specific test file
$ python test_updater.py TestUpdater.test_4_refresh # run a specific test
$ python test_updater.py -vvvv TestUpdater.test_4_refresh # run test with DEBUG log level


To run the tests and measure their code coverage, the aggregation script can be
invoked with the ``coverage`` tool (requires installation of ``coverage``, e.g.
Expand Down
3 changes: 3 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta

import utils

# TODO: Remove case handling when fully dropping support for versions >= 3.6
IS_PY_VERSION_SUPPORTED = sys.version_info >= (3, 6)

Expand Down Expand Up @@ -258,4 +260,5 @@ def test_metadata_timestamp(self):

# Run unit test.
if __name__ == '__main__':
utils.configure_test_logging(sys.argv)
unittest.main()
2 changes: 2 additions & 0 deletions tests/test_arbitrary_package_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import subprocess
import logging
import unittest
import sys

import tuf
import tuf.formats
Expand Down Expand Up @@ -302,4 +303,5 @@ def test_with_tuf_and_metadata_tampering(self):


if __name__ == '__main__':
utils.configure_test_logging(sys.argv)
unittest.main()
4 changes: 4 additions & 0 deletions tests/test_developer_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import logging
import tempfile
import shutil
import sys

import tuf
import tuf.log
Expand All @@ -40,6 +41,8 @@
from tuf.developer_tool import METADATA_DIRECTORY_NAME
from tuf.developer_tool import TARGETS_DIRECTORY_NAME

import utils

logger = logging.getLogger(__name__)

developer_tool.disable_console_log_messages()
Expand Down Expand Up @@ -423,4 +426,5 @@ def test_write(self):


if __name__ == '__main__':
utils.configure_test_logging(sys.argv)
unittest.main()
1 change: 1 addition & 0 deletions tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,5 @@ def popen_python(command_arg_list):

# Run unit test.
if __name__ == '__main__':
utils.configure_test_logging(sys.argv)
unittest.main()
2 changes: 2 additions & 0 deletions tests/test_endless_data_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import subprocess
import logging
import unittest
import sys

import tuf
import tuf.formats
Expand Down Expand Up @@ -290,4 +291,5 @@ def test_with_tuf(self):


if __name__ == '__main__':
utils.configure_test_logging(sys.argv)
unittest.main()
59 changes: 0 additions & 59 deletions tests/test_exceptions.py

This file was deleted.

2 changes: 2 additions & 0 deletions tests/test_extraneous_dependencies_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import subprocess
import logging
import unittest
import sys

import tuf.formats
import tuf.log
Expand Down Expand Up @@ -234,4 +235,5 @@ def test_with_tuf(self):


if __name__ == '__main__':
utils.configure_test_logging(sys.argv)
unittest.main()
4 changes: 4 additions & 0 deletions tests/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@

import unittest
import datetime
import sys

import tuf
import tuf.formats

import utils

import securesystemslib
import six

Expand Down Expand Up @@ -968,4 +971,5 @@ def test_encode_canonical(self):

# Run unit test.
if __name__ == '__main__':
utils.configure_test_logging(sys.argv)
unittest.main()
2 changes: 2 additions & 0 deletions tests/test_indefinite_freeze_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import subprocess
import logging
import unittest
import sys

import tuf.formats
import tuf.log
Expand Down Expand Up @@ -504,4 +505,5 @@ def test_with_tuf(self):


if __name__ == '__main__':
utils.configure_test_logging(sys.argv)
unittest.main()
75 changes: 0 additions & 75 deletions tests/test_init.py

This file was deleted.

2 changes: 2 additions & 0 deletions tests/test_key_revocation_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import random
import subprocess
import unittest
import sys

import tuf
import tuf.log
Expand Down Expand Up @@ -514,4 +515,5 @@ def _load_role_keys(keystore_directory):


if __name__ == '__main__':
utils.configure_test_logging(sys.argv)
unittest.main()
4 changes: 4 additions & 0 deletions tests/test_keydb.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import unittest
import logging
import sys

import tuf
import tuf.formats
Expand All @@ -38,6 +39,8 @@
import tuf.keydb
import tuf.log

import utils

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -408,4 +411,5 @@ def test_create_keydb_from_root_metadata(self):

# Run unit test.
if __name__ == '__main__':
utils.configure_test_logging(sys.argv)
unittest.main()
9 changes: 9 additions & 0 deletions tests/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import unittest
import os
import shutil
import sys

import tuf
import tuf.log
Expand All @@ -32,6 +33,8 @@
import securesystemslib
import securesystemslib.util

import utils

from six.moves import reload_module

# We explicitly create a logger which is a child of the tuf hierarchy,
Expand All @@ -46,10 +49,15 @@

class TestLog(unittest.TestCase):

def setUp(self):
# store the current log level so it can be restored after the test
self._initial_level = logging.getLogger('tuf').level

def tearDown(self):
tuf.log.remove_console_handler()
tuf.log.disable_file_logging()
logging.getLogger('tuf').level = self._initial_level




Expand Down Expand Up @@ -198,4 +206,5 @@ def test_disable_file_logging(self):

# Run unit test.
if __name__ == '__main__':
utils.configure_test_logging(sys.argv)
unittest.main()
4 changes: 4 additions & 0 deletions tests/test_mirrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@
from __future__ import unicode_literals

import unittest
import sys

import tuf.mirrors as mirrors
import tuf.unittest_toolbox as unittest_toolbox

import utils

import securesystemslib
import securesystemslib.util
import six
Expand Down Expand Up @@ -111,4 +114,5 @@ def test_get_list_of_mirrors(self):

# Run the unittests
if __name__ == '__main__':
utils.configure_test_logging(sys.argv)
unittest.main()
2 changes: 2 additions & 0 deletions tests/test_mix_and_match_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import subprocess
import logging
import unittest
import sys

import tuf.exceptions
import tuf.log
Expand Down Expand Up @@ -255,4 +256,5 @@ def test_with_tuf(self):


if __name__ == '__main__':
utils.configure_test_logging(sys.argv)
unittest.main()
2 changes: 2 additions & 0 deletions tests/test_multiple_repositories_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import shutil
import unittest
import json
import sys

import tuf
import tuf.log
Expand Down Expand Up @@ -301,4 +302,5 @@ def test_repository_tool(self):


if __name__ == '__main__':
utils.configure_test_logging(sys.argv)
unittest.main()
Loading