Skip to content
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

Rearrange directories + minor CI updates #34

Merged
merged 2 commits into from
Sep 4, 2023
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
7 changes: 3 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.7, 3.8, 3.9, "3.10", 3.11]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -27,12 +27,11 @@ jobs:
pip install pyflakes pytest pytest-doctestplus ruff
- name: Lint
run: |
ruff --select=A,B,E,F,PLC,PLE,PLW,SIM,W --ignore=B023,B904,E402,PLC1901,SIM115 --line-length=263 --statistics .
ruff --select=A,B,E,F,PLC,PLE,PLW,SIM,W --ignore=B023,B904,E402,PLC1901,SIM115,B018 --line-length=263 --statistics .
python -We:invalid -We::SyntaxWarning -m compileall -f -q removestar/
- name: Test
run: |
pytest
- name: Install
run: |
# Make sure it installs
python setup.py install
python -m pip install .
File renamed without changes.
28 changes: 14 additions & 14 deletions removestar/tests/test_removestar.py → tests/test_removestar.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
from pytest import raises
import pytest

from ..removestar import (names_to_replace, star_imports, get_names,
get_names_from_dir, get_names_dynamically, fix_code,
get_mod_filename, replace_imports,
is_noqa_comment_allowing_star_import,
ExternalModuleError)
from removestar.removestar import (names_to_replace, star_imports, get_names,
get_names_from_dir, get_names_dynamically, fix_code,
get_mod_filename, replace_imports,
is_noqa_comment_allowing_star_import,
ExternalModuleError)


code_mod1 = """\
Expand Down Expand Up @@ -1157,7 +1157,7 @@ def _dirs_equal(cmp):
return all(_dirs_equal(c) for c in cmp.subdirs.values())

def test_cli(tmpdir):
from ..__main__ import __file__
from removestar.__main__ import __file__

# TODO: Test the verbose and quiet flags
directory_orig = tmpdir/'orig'/'module'
Expand All @@ -1170,12 +1170,12 @@ def test_cli(tmpdir):

# Make sure we are running the command for the right file
p = subprocess.run([sys.executable, '-m', 'removestar', '--_this-file', 'none'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8')
stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8', check=True)
assert p.stderr == ''
assert p.stdout == __file__

p = subprocess.run([sys.executable, '-m', 'removestar', directory],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8')
stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8', check=True)
warnings = set(f"""\
Warning: {directory}/submod/submod1.py: 'b' comes from multiple modules: '..mod1', '..mod2'. Using '..mod2'.
Warning: {directory}/submod/submod1.py: could not find import for 'd'
Expand Down Expand Up @@ -1330,7 +1330,7 @@ def func():
assert _dirs_equal(cmp)

p = subprocess.run([sys.executable, '-m', 'removestar', '--quiet', directory],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8')
stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8', check=True)
assert p.stderr == ''
for d in diffs:
assert d in p.stdout
Expand All @@ -1339,7 +1339,7 @@ def func():

p = subprocess.run([sys.executable, '-m', 'removestar', '--verbose', directory],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
encoding='utf-8')
encoding='utf-8', check=True)
changes = set(f"""\
{directory}/mod4.py: Replacing 'from .mod1 import *' with 'from .mod1 import a'
{directory}/mod4.py: Replacing 'from .mod2 import *' with 'from .mod2 import b, c'
Expand Down Expand Up @@ -1372,7 +1372,7 @@ def func():

p = subprocess.run([sys.executable, '-m', 'removestar', '--no-dynamic-importing', directory],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
encoding='utf-8')
encoding='utf-8', check=True)
static_error = set(f"""\
Error with {directory}/mod6.py: Static determination of external module imports is not supported.
Error with {directory}/mod7.py: Static determination of external module imports is not supported.
Expand All @@ -1389,7 +1389,7 @@ def func():
# Test --quiet hides both errors
p = subprocess.run([sys.executable, '-m', 'removestar', '--quiet', '--no-dynamic-importing', directory],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
encoding='utf-8')
encoding='utf-8', check=True)
assert p.stderr == ''
for d in diffs:
if 'mod6' in d:
Expand All @@ -1401,7 +1401,7 @@ def func():

# XXX: This modifies directory, so keep it at the end of the test
p = subprocess.run([sys.executable, '-m', 'removestar', '--quiet', '-i', directory],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8')
stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8', check=True)
assert p.stderr == ''
assert p.stdout == ''
cmp = dircmp(directory, directory_orig)
Expand Down Expand Up @@ -1439,6 +1439,6 @@ def func():
# Test error on nonexistent file
p = subprocess.run([sys.executable, '-m', 'removestar', directory/'notarealfile.py'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
encoding='utf-8')
encoding='utf-8', check=True)
assert p.stderr == f'Error: {directory}/notarealfile.py: no such file or directory\n'
assert p.stdout == ''