diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d6b1ab11..ce65c64f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,6 +16,7 @@ jobs: env: DEBUG_TEST_PYFLYBY: 1 + ENVNAME: ${{matrix.os}}-${{matrix.python-version}} steps: - uses: actions/checkout@v3 @@ -33,7 +34,7 @@ jobs: if: ${{ matrix.python-version != '2.7'}} run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade "pexpect>=3.3" 'pytest<7' rlipython ipykernel==5.4.3 requests jupyter flaky 'notebook<6.1' 'prompt_toolkit<3.0.15' wheel 'jupyter_console>=6.2' 'pytest-cov<3' ipython 'coverage<6.3' + python -m pip install --upgrade "pexpect>=3.3" 'pytest<7' rlipython ipykernel==5.4.3 requests jupyter flaky 'notebook<6.1' 'prompt_toolkit<3.0.15' wheel 'jupyter_console>=6.2' 'pytest-cov<3' ipython 'coverage<6.3' pytest-json-report pip install -e . - name: test release build run: | @@ -41,9 +42,25 @@ jobs: - name: compileall run: | python -We:invalid -m compileall -f -q lib/ etc/; - - name: pytest + - name: pytest Python 2 or Mac OS + if: ${{ matrix.python-version == '2.7' || matrix.os == 'macos-latest'}} + # json report can't be installed on Py2, and make macos super slow. run: | python -m pytest --cov=pyflyby --cov-report=xml --doctest-modules --maxfail=3 lib tests + - name: pytest Python 3 + if: ${{ matrix.python-version != '2.7' && matrix.os != 'macos-latest' }} + run: | + python -m pytest --cov=pyflyby --cov-report=xml\ + --doctest-modules\ + --maxfail=3\ + --json-report\ + --json-report-file=report-${ENVNAME}.json\ + lib tests + - uses: actions/upload-artifact@v3 + name: upload pytest timing reports as json + with: + path: | + ./report-*.json - uses: codecov/codecov-action@v2 - name: Build docs if: ${{ matrix.python-version == '3.10'}} diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..27f9ddd3 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,16 @@ +coverage: + status: + project: + default: + threshold: 1% + target: 70% + patch: + default: + threshold: 1% + target: 0% +codecov: + notify: + after_n_builds: 6 +comment: + require_changes: true # if true: only post the PR comment if coverage changes + after_n_builds: 6 diff --git a/tests/test_interactive.py b/tests/test_interactive.py index 75ebc902..0d46704b 100644 --- a/tests/test_interactive.py +++ b/tests/test_interactive.py @@ -4183,11 +4183,44 @@ def test_debug_postmortem_tab_completion_1(frontend): """, frontend=frontend) -@pytest.mark.xfail( +@pytest.mark.skipif( + sys.version_info[0] == 2, + reason="[PYFLYBY] import base64 is not triggered at the same time depending on python versions", +) +def test_debug_namespace_1_py3(frontend): + # Verify that autoimporting and tab completion happen in the local + # namespace. + # In this example, in the local namespace, 'base64' is a variable (which + # is a string), and shouldn't refer to the global 'base64'. + ipython(""" + In [1]: import pyflyby; pyflyby.enable_auto_importer() + In [2]: def foo(x, base64): + ...: return x / base64 + ...: + In [3]: foo("Lexington", "atlantic") + --------------------------------------------------------------------------- + TypeError Traceback (most recent call last) + .... + TypeError: unsupported operand type(s) for /: 'str' and 'str' + In [4]: %debug + .... + ipdb> print(base64.cap\titalize() + b64deco\tde("UGFjaWZpYw==").decode('utf-8')) + [PYFLYBY] from base64 import b64decode + AtlanticPacific + ipdb> p b64deco\tde("Q29udGluZW50YWw=") + b'Continental' + ipdb> q + In [5]: base64.b64de\t + In [5]: base64.b64decode("SGlsbA==") + b64deco\tde("TGFrZQ==") + [PYFLYBY] from base64 import b64decode + Out[5]: b'HillLake' + """, frontend=frontend) + +@pytest.mark.skipif( sys.version_info[0] == 3, reason="[PYFLYBY] import base64 is not triggered at the same time depending on python versions", ) -def test_debug_namespace_1(frontend): +def test_debug_namespace_1_py2(frontend): # Verify that autoimporting and tab completion happen in the local # namespace. # In this example, in the local namespace, 'base64' is a variable (which