Skip to content

Commit

Permalink
Ensure test quality via linting (#42)
Browse files Browse the repository at this point in the history
- Start specifying encoding when opening a file
- Use f-strings
- List standard modules first in imports.
- Avoid visual indenting
  • Loading branch information
akosthekiss committed Nov 10, 2023
1 parent a5fe331 commit e80f620
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/resources/sut-json-load.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys


with open(sys.argv[1], 'r') as f:
with open(sys.argv[1], 'r', encoding='utf-8') as f:
j = json.load(f)

print(repr(j))
print(f'{j!r}')
9 changes: 5 additions & 4 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Copyright (c) 2016-2022 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 subprocess
import sys

import pytest


is_windows = sys.platform.startswith('win32')
script_ext = '.bat' if is_windows else '.sh'
Expand Down Expand Up @@ -40,8 +41,8 @@
def test_cli(test, inp, exp, grammar, rule, input_format, args, tmpdir):
out_dir = str(tmpdir)
cmd = (sys.executable, '-m', 'picireny') \
+ (f'--test={test}{script_ext}', f'--input={inp}', f'--out={out_dir}') \
+ ('--log-level=TRACE', )
+ (f'--test={test}{script_ext}', f'--input={inp}', f'--out={out_dir}') \
+ ('--log-level=TRACE', )
if grammar:
cmd += (f'--grammar={grammar}', )
if rule:
Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ omit = **/parser/*
deps =
pycodestyle
pylint
pytest
commands =
pylint picireny
pycodestyle picireny --ignore=E501 --exclude=picireny/antlr4/parser/ANTLRv4*.py
pylint picireny tests
pycodestyle picireny tests --ignore=E501 --exclude=picireny/antlr4/parser/ANTLRv4*.py

[testenv:build]
deps =
Expand Down

0 comments on commit e80f620

Please sign in to comment.