Skip to content

Commit

Permalink
fixed test and CI/CD for test
Browse files Browse the repository at this point in the history
  • Loading branch information
AxelGard committed Jun 11, 2024
1 parent 594af08 commit ef1414c
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 14 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build and Test [Python 3.8]


on:
push:
branches: [ main ]
pull_request:
branches: [ main, develop ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -e .
- name: Test with pytest
run: |
pytest
File renamed without changes.
6 changes: 6 additions & 0 deletions tests/.ex/dir/sub_dir/foo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import math

def inverse_sqrt(x:int):
""" a normal inverse square root """
assert x != 0, "x must not be equal to zero"
return 1 / math.sqrt(x)
Empty file removed tests/test_dir.py
Empty file.
41 changes: 41 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import subprocess
import pathlib


def test_integration_simple_file():
test_dir = pathlib.Path().resolve()
file_to_parse = './tests/.ex/add.py'
command = ['python3', '-m', 'inkpot', file_to_parse]
result = subprocess.check_output(command, cwd=test_dir, text=True)
expected = "# ./tests/.ex/add.py\n## ./tests/.ex/add.py\n**def add(a, b)** \\\n`add to objects ` \n\n\n"
assert result == expected, f"Failed to parse {file_to_parse}"


def test_integration_type_anotations():
test_dir = pathlib.Path().resolve()
file_to_parse = './tests/.ex/typed.py'
command = ['python3', '-m', 'inkpot', file_to_parse]
result = subprocess.check_output(command, cwd=test_dir, text=True)
expected = '# ./tests/.ex/typed.py\n## ./tests/.ex/typed.py\n**def add_one(x: int) -> int** \\\n`None` \n\n\n'
assert result == expected, f"Failed to parse {file_to_parse}"


def test_integration_classes():
test_dir = pathlib.Path().resolve()
file_to_parse = './tests/.ex/car.py'
command = ['python3', '-m', 'inkpot', file_to_parse]
result = subprocess.check_output(command, cwd=test_dir, text=True)
expected = '# ./tests/.ex/car.py\n## ./tests/.ex/car.py\n### class Car()\n`The Car class` \n\n> ### class Engine()\n> `The Engine subclass` \n>\n>> **def \\_\\_init\\_\\_(self)** \\\n>> `None` \n>>\n> **def \\_\\_init\\_\\_(self)** \\\n> `None` \n>\n> **def start(self, time: str, car_key)** \\\n> `starts the engine of the car` \n>\n> **def stop(self, a=1, b=2, c=None, \\*args, \\*\\*kwargs)** \\\n> `Stop the engine of the car!` \n>\n> **def honk(self)** \\\n> `Use` \\\n`"the"` \\\n`""horn""` \n>\n>> **def nested_test()** \\\n>> `nested function inside honk` \n>>\n> **def \\_\\_str\\_\\_(self)** \\\n> `Example of a longer multiline-docstring,` \\\n`everything will still be formatted correctly` \n>\n> **@staticmethod \\\n@staticmethod \\\ndef funcname(param1: str, param2: int)** \\\n> `The docstring to the static method` \n>\n**async def async_def_test(a, b, c)** \\\n`Testing coroutines declared with async syntax` \n\n**def no_class_def_test()** \\\n`None` \n\n\n'
assert result == expected, f"Failed to parse {file_to_parse}"


def test_integration_dir():
test_dir = pathlib.Path().resolve()
file_to_parse = './tests/.ex/dir/'
command = ['python3', '-m', 'inkpot', file_to_parse]
result = subprocess.check_output(command, cwd=test_dir, text=True)
expected = '# ./tests/.ex/dir/\n## ./tests/.ex/dir/point.py\n### class Point()\n`Creates a point on a coordinate plane with values x and y.` \n\n> **def \\_\\_init\\_\\_(self, x_init, y_init)** \\\n> `Defines x and y variables` \n>\n> **def shift(self, x, y)** \\\n> `Determines where x and y move` \n>\n> **def \\_\\_repr\\_\\_(self)** \\\n> `None` \n>\n\n## ./tests/.ex/dir/sub_dir/foo.py\n**def inverse_sqrt(x: int)** \\\n`a normal inverse square root ` \n\n\n'
assert result == expected, f"Failed to parse {file_to_parse}"


#print(repr(result))
14 changes: 0 additions & 14 deletions tests/test_singel_file.py

This file was deleted.

0 comments on commit ef1414c

Please sign in to comment.