diff --git a/.github/workflows/install_check.yml b/.github/workflows/install_check.yml new file mode 100644 index 0000000..86edb8a --- /dev/null +++ b/.github/workflows/install_check.yml @@ -0,0 +1,37 @@ +name: Install from Source Check + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + release: + types: [published] + +jobs: + install-test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11'] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install from source + run: | + python -m pip install --upgrade pip + pip install . + + - name: Verify installation + run: | + # Change directory to ensure we test the installed package, not the local source + mkdir test_verification + cp tests/verify_install.py test_verification/ + cd test_verification + python verify_install.py diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..d7ed81f --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,31 @@ +name: Linting + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install linters + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pycodestyle pydocstyle + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Lint with pycodestyle + run: pycodestyle delayed_assert/ + - name: Lint with pydocstyle + run: pydocstyle delayed_assert/ diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml deleted file mode 100644 index 6a073f7..0000000 --- a/.github/workflows/python-package.yml +++ /dev/null @@ -1,44 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Python package - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: [3.8, 3.9, '3.10', '3.11'] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install flake8 pytest pytest-xdist pycodestyle pydocstyle - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Lint with pycodestyle and pydocstyle - run: | - pycodestyle delayed_assert/ - pydocstyle delayed_assert/ - - name: Run test - run: | - pytest -n auto diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..3e044b4 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,30 @@ +name: Tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: [3.8, 3.9, '3.10', '3.11'] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pytest pytest-xdist + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Run tests (Parallel) + run: | + pytest -n auto diff --git a/tests/verify_install.py b/tests/verify_install.py new file mode 100644 index 0000000..91db3e5 --- /dev/null +++ b/tests/verify_install.py @@ -0,0 +1,46 @@ +import delayed_assert +import sys + +print(f'Successfully imported delayed_assert from {delayed_assert.__file__}') + +from delayed_assert import expect, assert_expectations, test_case, set_check_caller + +# Verify basic functionality +# We must disable caller check because we are calling expect() from top-level scope +set_check_caller(False) +try: + expect(1 == 1) + assert_expectations() + print('Basic functionality verification passed') +except Exception as e: + print(f'Failed: {e}') + sys.exit(1) + +# Re-enable for decorator check (though decorator handles it regardless of flag? +# No, decorator sets context, which expect() checks. Flag only matters if context/stack fails.) +set_check_caller(True) + +# Verify @test_case matches +@test_case +def run_check(): + expect(1 == 1) + +try: + run_check() + assert_expectations() + print('Decorator verification passed') +except Exception as e: + print(f'Decorator Failed: {e}') + sys.exit(1) + +# Verify that test files are NOT installed as top-level modules +modules_to_check = ['test_issue_15', 'test_color_toggle', 'test_issue_33'] +print('Verifying test modules are not leaking...') +for module in modules_to_check: + try: + __import__(module) + print(f'ERROR: {module} was definitely imported! It should not be installed.') + sys.exit(1) + except ImportError: + pass # This is expected +print('Clean installation verified (no test modules leaked)')