Skip to content

Commit

Permalink
Ensure test quality via linting (#72)
Browse files Browse the repository at this point in the history
- Change test folders to packages to allow relative imports
- List standard modules first in imports
- Avoid unnecessary indenting of brackets
- Use whitespace around binary operators
  • Loading branch information
akosthekiss authored Nov 12, 2023
1 parent 68cb477 commit e776b5c
Show file tree
Hide file tree
Showing 32 changed files with 134 additions and 62 deletions.
8 changes: 8 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.

# INTENTIONALLY EMPTY
8 changes: 8 additions & 0 deletions tests/call/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.

# INTENTIONALLY EMPTY
4 changes: 2 additions & 2 deletions tests/call/test_anonymize_decorator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2016-2021 Renata Hodovan, Akos Kiss.
# Copyright (c) 2016-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
Expand All @@ -9,7 +9,7 @@

import fuzzinator

from common_call import MockAlwaysFailCall, MockNeverFailCall
from .common_call import MockAlwaysFailCall, MockNeverFailCall


@pytest.mark.parametrize('call_init_kwargs, call_kwargs', [
Expand Down
4 changes: 2 additions & 2 deletions tests/call/test_exit_code_filter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2016-2021 Renata Hodovan, Akos Kiss.
# Copyright (c) 2016-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
Expand All @@ -9,7 +9,7 @@

import fuzzinator

from common_call import MockAlwaysFailCall, MockNeverFailCall
from .common_call import MockAlwaysFailCall, MockNeverFailCall


@pytest.mark.parametrize('call_init_kwargs, call_kwargs', [
Expand Down
7 changes: 4 additions & 3 deletions tests/call/test_file_reader_decorator.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Copyright (c) 2017-2022 Renata Hodovan, Akos Kiss.
# Copyright (c) 2017-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.

import os
import pytest
import shutil

import pytest

import fuzzinator

from common_call import blinesep, resources_dir, MockAlwaysFailCall, MockNeverFailCall
from .common_call import blinesep, resources_dir, MockAlwaysFailCall, MockNeverFailCall


@pytest.mark.parametrize('dec_kwargs', [
Expand Down
7 changes: 4 additions & 3 deletions tests/call/test_file_writer_decorator.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Copyright (c) 2016-2021 Renata Hodovan, Akos Kiss.
# Copyright (c) 2016-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.

import os
import pytest
import re

import pytest

import fuzzinator

from common_call import MockAlwaysFailCall, MockNeverFailCall
from .common_call import MockAlwaysFailCall, MockNeverFailCall


@pytest.mark.parametrize('call_init_kwargs, call_kwargs', [
Expand Down
4 changes: 2 additions & 2 deletions tests/call/test_platform_info_decorator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2016-2021 Renata Hodovan, Akos Kiss.
# Copyright (c) 2016-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
Expand All @@ -9,7 +9,7 @@

import fuzzinator

from common_call import MockAlwaysFailCall, MockNeverFailCall
from .common_call import MockAlwaysFailCall, MockNeverFailCall


@pytest.mark.parametrize('call_init_kwargs, call_kwargs', [
Expand Down
4 changes: 2 additions & 2 deletions tests/call/test_regex_filter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2016-2021 Renata Hodovan, Akos Kiss.
# Copyright (c) 2016-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
Expand All @@ -9,7 +9,7 @@

import fuzzinator

from common_call import MockAlwaysFailCall, MockNeverFailCall
from .common_call import MockAlwaysFailCall, MockNeverFailCall


@pytest.mark.parametrize('call_init_kwargs, call_kwargs', [
Expand Down
5 changes: 3 additions & 2 deletions tests/call/test_sanitizer_analyzer_decorator.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Copyright (c) 2020 Tamas Keri
# Copyright (c) 2020-2021 Renata Hodovan, Akos Kiss.
# Copyright (c) 2020-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.

import os

import pytest

import fuzzinator

from common_call import resources_dir, MockAlwaysFailCall
from .common_call import resources_dir, MockAlwaysFailCall


@pytest.mark.parametrize('call_class, call_kwargs, exp', [
Expand Down
7 changes: 4 additions & 3 deletions tests/call/test_stdin_subprocess_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
# according to those terms.

import os
import pytest
import sys

import pytest

import fuzzinator

from common_call import linesep, resources_dir
from .common_call import linesep, resources_dir


@pytest.mark.parametrize('command, cwd, env, no_exit_code, test, exp', [
Expand All @@ -21,7 +22,7 @@
(f'{sys.executable} {os.path.join(resources_dir, "mock_tool.py")} --echo-stdin --exit-code 1', resources_dir, None, None, b'foo', {'stdout': 'foo', 'stderr': '', 'exit_code': 1}),
(f'{sys.executable} {os.path.join(resources_dir, "mock_tool.py")} --print-env BAR --echo-stdin --exit-code 1', resources_dir, '{"BAR": "baz"}', None, b'foo', {'stdout': f'baz{linesep}foo', 'stderr': '', 'exit_code': 1}),
(f'{sys.executable} {os.path.join(resources_dir, "mock_tool.py")} --echo-stdin --exit-code 0', None, None, 'True', b'foo', {'stdout': 'foo', 'stderr': '', 'exit_code': 0}),
])
])
def test_stdin_subprocess_call(command, cwd, env, no_exit_code, test, exp):
call = fuzzinator.call.StdinSubprocessCall(command=command, cwd=cwd, env=env, no_exit_code=no_exit_code)
with call:
Expand Down
5 changes: 3 additions & 2 deletions tests/call/test_stream_monitored_subprocess_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
# according to those terms.

import os
import pytest
import sys

import pytest

import fuzzinator

from common_call import linesep, resources_dir
from .common_call import linesep, resources_dir


@pytest.mark.skipif(not hasattr(fuzzinator.call, 'StreamMonitoredSubprocessCall'),
Expand Down
5 changes: 3 additions & 2 deletions tests/call/test_subprocess_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
# according to those terms.

import os
import pytest
import sys

import pytest

import fuzzinator

from common_call import linesep, resources_dir
from .common_call import linesep, resources_dir


@pytest.mark.parametrize('command, cwd, env, no_exit_code, test, exp', [
Expand Down
5 changes: 3 additions & 2 deletions tests/call/test_subprocess_property_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
# according to those terms.

import os
import pytest
import sys

import pytest

import fuzzinator

from common_call import linesep, resources_dir, MockAlwaysFailCall, MockNeverFailCall
from .common_call import linesep, resources_dir, MockAlwaysFailCall, MockNeverFailCall


@pytest.mark.parametrize('call_init_kwargs, call_kwargs', [
Expand Down
4 changes: 2 additions & 2 deletions tests/call/test_unique_decorator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2016-2021 Renata Hodovan, Akos Kiss.
# Copyright (c) 2016-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
Expand All @@ -9,7 +9,7 @@

import fuzzinator

from common_call import MockAlwaysFailCall, MockNeverFailCall
from .common_call import MockAlwaysFailCall, MockNeverFailCall


@pytest.mark.parametrize('call_init_kwargs, call_kwargs', [
Expand Down
8 changes: 8 additions & 0 deletions tests/exporter/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.

# INTENTIONALLY EMPTY
8 changes: 8 additions & 0 deletions tests/formatter/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.

# INTENTIONALLY EMPTY
5 changes: 3 additions & 2 deletions tests/formatter/test_chevron_formatter.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Copyright (c) 2018-2022 Renata Hodovan, Akos Kiss.
# Copyright (c) 2018-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.

import os

import pytest

import fuzzinator

from common_formatter import mock_issue, mock_templates_dir
from .common_formatter import mock_issue, mock_templates_dir


@pytest.mark.parametrize('issue, formatter_init_kwargs, exp_short, exp_long', [
Expand Down
5 changes: 3 additions & 2 deletions tests/formatter/test_jinja_formatter.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Copyright (c) 2018-2022 Renata Hodovan, Akos Kiss.
# Copyright (c) 2018-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.

import os

import pytest

import fuzzinator

from common_formatter import mock_issue, mock_templates_dir
from .common_formatter import mock_issue, mock_templates_dir


@pytest.mark.parametrize('issue, formatter_init_kwargs, exp_short, exp_long', [
Expand Down
4 changes: 2 additions & 2 deletions tests/formatter/test_markdown_decorator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2018-2022 Renata Hodovan, Akos Kiss.
# Copyright (c) 2018-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
Expand All @@ -9,7 +9,7 @@

import fuzzinator

from common_formatter import MockFixedFormatter, MockIdFormatter
from .common_formatter import MockFixedFormatter, MockIdFormatter


@pytest.mark.parametrize('issue, formatter_class, formatter_init_kwargs, exp_short, exp_long', [
Expand Down
5 changes: 3 additions & 2 deletions tests/formatter/test_string_formatter.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Copyright (c) 2018-2021 Renata Hodovan, Akos Kiss.
# Copyright (c) 2018-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.

import os

import pytest

import fuzzinator

from common_formatter import mock_issue, mock_templates_dir
from .common_formatter import mock_issue, mock_templates_dir


@pytest.mark.parametrize('issue, formatter_init_kwargs, exp_short, exp_long', [
Expand Down
8 changes: 8 additions & 0 deletions tests/fuzzer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.

# INTENTIONALLY EMPTY
4 changes: 2 additions & 2 deletions tests/fuzzer/test_byte_flip_decorator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2017-2021 Renata Hodovan, Akos Kiss.
# Copyright (c) 2017-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
Expand All @@ -9,7 +9,7 @@

import fuzzinator

from common_fuzzer import MockExhaustedFuzzer, MockRepeatingFuzzer
from .common_fuzzer import MockExhaustedFuzzer, MockRepeatingFuzzer


@pytest.mark.parametrize('fuzzer_class, fuzzer_init_kwargs, dec_kwargs, exp_flip_cnt', [
Expand Down
7 changes: 4 additions & 3 deletions tests/fuzzer/test_fuzzer_file_writer_decorator.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Copyright (c) 2017-2021 Renata Hodovan, Akos Kiss.
# Copyright (c) 2017-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.

import os
import pytest
import re

import pytest

import fuzzinator

from common_fuzzer import MockExhaustedFuzzer, MockRepeatingFuzzer
from .common_fuzzer import MockExhaustedFuzzer, MockRepeatingFuzzer


@pytest.mark.parametrize('fuzzer_class, fuzzer_init_kwargs, dec_kwargs, exp', [
Expand Down
8 changes: 4 additions & 4 deletions tests/fuzzer/test_list_directory.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Copyright (c) 2016-2021 Renata Hodovan, Akos Kiss.
# Copyright (c) 2016-2023 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
# This file may not be copied, modified, or distributed except
# according to those terms.

import pytest

from os.path import join

import pytest

import fuzzinator

from common_fuzzer import blinesep, resources_dir
from .common_fuzzer import blinesep, resources_dir

mock_tests = join(resources_dir, 'mock_tests')

Expand Down
Loading

0 comments on commit e776b5c

Please sign in to comment.