Skip to content

Commit

Permalink
feat: added test and updated the workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishabh672003 committed Jul 1, 2024
1 parent 03929d0 commit 4a1b03d
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 11 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,26 @@ permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
Testing:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8, 3.9,"3.10", "3.11", "3.12"]
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v4
- name: Setup PDM
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pdm install && pip install ruff
run: |
pdm sync -d -G tests lint; pip install ruff
- name: Run Tests
run: |
pdm run -v pytest tests
- name: Lint with ruff
run: |
ruff check .
58 changes: 54 additions & 4 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ build-backend = "pdm.backend"
distribution = true

[tool.pdm.dev-dependencies]
lint = [
"ruff>=0.5.0",
]
lint = ["ruff>=0.5.0"]
tests = ["pytest>=8.2.2"]

[project.scripts]
pyfix-imports = "pyfix_imports.commandline.cli:cli"

[tool.pytest.ini_options]
# addopts = "--cov=pyfix_imports"
# testpaths = ["tests"]
15 changes: 15 additions & 0 deletions tests/mod_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pyfix_imports.pyflake import pyflake
from tests.test import test_code

def check_code(output):
mod_list = pyflake(output)

if mod_list:
return mod_list
else:
return {}


def test_code_output():
assert check_code(test_code) == {'defaultdict', 'Tuple', 'List', 'mp', 'Optional', 'time', 'np', 'deque', 'os', 'itertools', 'Dict', 'dedent', 'collections', 'random'}

32 changes: 32 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
test_code = """
start = time.time()
a = np.array([1, 2, 3, 4])
b = os.getcwd()
c = random.randint(1, 3)
deq = deque()
a = dedent("121")
d = defaultdict(str)
a = mp.sqrt_mod(12, 2)
itt = itertools.accumulate([1, 2, 3, 4])
print(list(itt))
assert list(itt) == [1, 3, 6, 10]
Points = collections.namedtuple("Point", ["x", "y"])
def fname(a: Dict[int, List], b: Tuple[int], c: Optional[List]):
pass
z = os.getcwd()
end = time.time()
print(end - start)
"""

0 comments on commit 4a1b03d

Please sign in to comment.