Show More
@@ -1,59 +1,60 | |||||
1 | name: Run tests |
|
1 | name: Run tests | |
2 |
|
2 | |||
3 | on: |
|
3 | on: | |
4 | push: |
|
4 | push: | |
5 | pull_request: |
|
5 | pull_request: | |
6 | # Run weekly on Monday at 1:23 UTC |
|
6 | # Run weekly on Monday at 1:23 UTC | |
7 | schedule: |
|
7 | schedule: | |
8 | - cron: '23 1 * * 1' |
|
8 | - cron: '23 1 * * 1' | |
9 | workflow_dispatch: |
|
9 | workflow_dispatch: | |
10 |
|
10 | |||
11 |
|
11 | |||
12 | jobs: |
|
12 | jobs: | |
13 | test: |
|
13 | test: | |
14 | runs-on: ${{ matrix.os }} |
|
14 | runs-on: ${{ matrix.os }} | |
15 | strategy: |
|
15 | strategy: | |
16 | matrix: |
|
16 | matrix: | |
17 | os: [ubuntu-latest] |
|
17 | os: [ubuntu-latest, windows-latest] | |
18 | python-version: ["3.7", "3.8", "3.9", "3.10"] |
|
18 | python-version: ["3.7", "3.8", "3.9", "3.10"] | |
19 | deps: [test_extra] |
|
19 | deps: [test_extra] | |
20 | # Test all on ubuntu, test ends on macos |
|
20 | # Test all on ubuntu, test ends on macos | |
21 | include: |
|
21 | include: | |
22 | - os: macos-latest |
|
22 | - os: macos-latest | |
23 | python-version: "3.7" |
|
23 | python-version: "3.7" | |
24 | deps: test_extra |
|
24 | deps: test_extra | |
25 | - os: macos-latest |
|
25 | - os: macos-latest | |
26 | python-version: "3.10" |
|
26 | python-version: "3.10" | |
27 | deps: test_extra |
|
27 | deps: test_extra | |
28 | # Tests minimal dependencies set |
|
28 | # Tests minimal dependencies set | |
29 | - os: ubuntu-latest |
|
29 | - os: ubuntu-latest | |
30 | python-version: "3.10" |
|
30 | python-version: "3.10" | |
31 | deps: test |
|
31 | deps: test | |
32 | # Tests latest development Python version |
|
32 | # Tests latest development Python version | |
33 | - os: ubuntu-latest |
|
33 | - os: ubuntu-latest | |
34 | python-version: "3.11-dev" |
|
34 | python-version: "3.11-dev" | |
35 | deps: test |
|
35 | deps: test | |
36 |
|
36 | |||
37 | steps: |
|
37 | steps: | |
38 | - uses: actions/checkout@v2 |
|
38 | - uses: actions/checkout@v2 | |
39 | - name: Set up Python ${{ matrix.python-version }} |
|
39 | - name: Set up Python ${{ matrix.python-version }} | |
40 | uses: actions/setup-python@v2 |
|
40 | uses: actions/setup-python@v2 | |
41 | with: |
|
41 | with: | |
42 | python-version: ${{ matrix.python-version }} |
|
42 | python-version: ${{ matrix.python-version }} | |
43 | - name: Install latex |
|
43 | - name: Install latex | |
44 | if: runner.os == 'Linux' && matrix.deps == 'test_extra' |
|
44 | if: runner.os == 'Linux' && matrix.deps == 'test_extra' | |
45 | run: sudo apt-get -yq -o Acquire::Retries=3 --no-install-suggests --no-install-recommends install texlive dvipng |
|
45 | run: sudo apt-get -yq -o Acquire::Retries=3 --no-install-suggests --no-install-recommends install texlive dvipng | |
46 | - name: Install and update Python dependencies |
|
46 | - name: Install and update Python dependencies | |
47 | run: | |
|
47 | run: | | |
48 | python -m pip install --upgrade pip setuptools wheel |
|
48 | python -m pip install --upgrade pip setuptools wheel | |
49 | python -m pip install --upgrade -e .[${{ matrix.deps }}] |
|
49 | python -m pip install --upgrade -e .[${{ matrix.deps }}] | |
50 | python -m pip install --upgrade check-manifest pytest-cov |
|
50 | python -m pip install --upgrade check-manifest pytest-cov | |
51 | - name: Check manifest |
|
51 | - name: Check manifest | |
|
52 | if: runner.os != 'Windows' # setup.py does not support sdist on Windows | |||
52 | run: check-manifest |
|
53 | run: check-manifest | |
53 | - name: pytest |
|
54 | - name: pytest | |
54 | env: |
|
55 | env: | |
55 | COLUMNS: 120 |
|
56 | COLUMNS: 120 | |
56 | run: | |
|
57 | run: | | |
57 | pytest --color=yes -v --cov --cov-report=xml |
|
58 | pytest --color=yes -ra -v --cov --cov-report=xml | |
58 | - name: Upload coverage to Codecov |
|
59 | - name: Upload coverage to Codecov | |
59 | uses: codecov/codecov-action@v2 |
|
60 | uses: codecov/codecov-action@v2 |
@@ -1,65 +1,66 | |||||
1 | import tempfile, os |
|
1 | import tempfile, os | |
|
2 | from pathlib import Path | |||
2 |
|
3 | |||
3 | from traitlets.config.loader import Config |
|
4 | from traitlets.config.loader import Config | |
4 |
|
5 | |||
5 |
|
6 | |||
6 | def setup_module(): |
|
7 | def setup_module(): | |
7 | ip.magic('load_ext storemagic') |
|
8 | ip.magic('load_ext storemagic') | |
8 |
|
9 | |||
9 | def test_store_restore(): |
|
10 | def test_store_restore(): | |
10 | assert 'bar' not in ip.user_ns, "Error: some other test leaked `bar` in user_ns" |
|
11 | assert 'bar' not in ip.user_ns, "Error: some other test leaked `bar` in user_ns" | |
11 | assert 'foo' not in ip.user_ns, "Error: some other test leaked `foo` in user_ns" |
|
12 | assert 'foo' not in ip.user_ns, "Error: some other test leaked `foo` in user_ns" | |
12 | assert 'foobar' not in ip.user_ns, "Error: some other test leaked `foobar` in user_ns" |
|
13 | assert 'foobar' not in ip.user_ns, "Error: some other test leaked `foobar` in user_ns" | |
13 | assert 'foobaz' not in ip.user_ns, "Error: some other test leaked `foobaz` in user_ns" |
|
14 | assert 'foobaz' not in ip.user_ns, "Error: some other test leaked `foobaz` in user_ns" | |
14 | ip.user_ns['foo'] = 78 |
|
15 | ip.user_ns['foo'] = 78 | |
15 | ip.magic('alias bar echo "hello"') |
|
16 | ip.magic('alias bar echo "hello"') | |
16 | ip.user_ns['foobar'] = 79 |
|
17 | ip.user_ns['foobar'] = 79 | |
17 | ip.user_ns['foobaz'] = '80' |
|
18 | ip.user_ns['foobaz'] = '80' | |
18 | tmpd = tempfile.mkdtemp() |
|
19 | tmpd = tempfile.mkdtemp() | |
19 | ip.magic('cd ' + tmpd) |
|
20 | ip.magic('cd ' + tmpd) | |
20 | ip.magic('store foo') |
|
21 | ip.magic('store foo') | |
21 | ip.magic('store bar') |
|
22 | ip.magic('store bar') | |
22 | ip.magic('store foobar foobaz') |
|
23 | ip.magic('store foobar foobaz') | |
23 |
|
24 | |||
24 | # Check storing |
|
25 | # Check storing | |
25 | assert ip.db["autorestore/foo"] == 78 |
|
26 | assert ip.db["autorestore/foo"] == 78 | |
26 | assert "bar" in ip.db["stored_aliases"] |
|
27 | assert "bar" in ip.db["stored_aliases"] | |
27 | assert ip.db["autorestore/foobar"] == 79 |
|
28 | assert ip.db["autorestore/foobar"] == 79 | |
28 | assert ip.db["autorestore/foobaz"] == "80" |
|
29 | assert ip.db["autorestore/foobaz"] == "80" | |
29 |
|
30 | |||
30 | # Remove those items |
|
31 | # Remove those items | |
31 | ip.user_ns.pop('foo', None) |
|
32 | ip.user_ns.pop('foo', None) | |
32 | ip.user_ns.pop('foobar', None) |
|
33 | ip.user_ns.pop('foobar', None) | |
33 | ip.user_ns.pop('foobaz', None) |
|
34 | ip.user_ns.pop('foobaz', None) | |
34 | ip.alias_manager.undefine_alias('bar') |
|
35 | ip.alias_manager.undefine_alias('bar') | |
35 | ip.magic('cd -') |
|
36 | ip.magic('cd -') | |
36 | ip.user_ns['_dh'][:] = [] |
|
37 | ip.user_ns['_dh'][:] = [] | |
37 |
|
38 | |||
38 | # Check restoring |
|
39 | # Check restoring | |
39 | ip.magic("store -r foo bar foobar foobaz") |
|
40 | ip.magic("store -r foo bar foobar foobaz") | |
40 | assert ip.user_ns["foo"] == 78 |
|
41 | assert ip.user_ns["foo"] == 78 | |
41 | assert ip.alias_manager.is_alias("bar") |
|
42 | assert ip.alias_manager.is_alias("bar") | |
42 | assert ip.user_ns["foobar"] == 79 |
|
43 | assert ip.user_ns["foobar"] == 79 | |
43 | assert ip.user_ns["foobaz"] == "80" |
|
44 | assert ip.user_ns["foobaz"] == "80" | |
44 |
|
45 | |||
45 | ip.magic("store -r") # restores _dh too |
|
46 | ip.magic("store -r") # restores _dh too | |
46 |
assert |
|
47 | assert any(Path(tmpd).samefile(p) for p in ip.user_ns["_dh"]) | |
47 |
|
48 | |||
48 | os.rmdir(tmpd) |
|
49 | os.rmdir(tmpd) | |
49 |
|
50 | |||
50 | def test_autorestore(): |
|
51 | def test_autorestore(): | |
51 | ip.user_ns['foo'] = 95 |
|
52 | ip.user_ns['foo'] = 95 | |
52 | ip.magic('store foo') |
|
53 | ip.magic('store foo') | |
53 | del ip.user_ns['foo'] |
|
54 | del ip.user_ns['foo'] | |
54 | c = Config() |
|
55 | c = Config() | |
55 | c.StoreMagics.autorestore = False |
|
56 | c.StoreMagics.autorestore = False | |
56 | orig_config = ip.config |
|
57 | orig_config = ip.config | |
57 | try: |
|
58 | try: | |
58 | ip.config = c |
|
59 | ip.config = c | |
59 | ip.extension_manager.reload_extension("storemagic") |
|
60 | ip.extension_manager.reload_extension("storemagic") | |
60 | assert "foo" not in ip.user_ns |
|
61 | assert "foo" not in ip.user_ns | |
61 | c.StoreMagics.autorestore = True |
|
62 | c.StoreMagics.autorestore = True | |
62 | ip.extension_manager.reload_extension("storemagic") |
|
63 | ip.extension_manager.reload_extension("storemagic") | |
63 | assert ip.user_ns["foo"] == 95 |
|
64 | assert ip.user_ns["foo"] == 95 | |
64 | finally: |
|
65 | finally: | |
65 | ip.config = orig_config |
|
66 | ip.config = orig_config |
@@ -1,29 +1,29 | |||||
1 | #----------------------------------------------------------------------------- |
|
1 | #----------------------------------------------------------------------------- | |
2 | # Copyright (C) 2012- The IPython Development Team |
|
2 | # Copyright (C) 2012- The IPython Development Team | |
3 | # |
|
3 | # | |
4 | # Distributed under the terms of the BSD License. The full license is in |
|
4 | # Distributed under the terms of the BSD License. The full license is in | |
5 | # the file COPYING, distributed as part of this software. |
|
5 | # the file COPYING, distributed as part of this software. | |
6 | #----------------------------------------------------------------------------- |
|
6 | #----------------------------------------------------------------------------- | |
7 |
|
7 | |||
8 | from pathlib import Path |
|
8 | from pathlib import Path | |
9 |
|
9 | |||
10 | from IPython.utils.tempdir import NamedFileInTemporaryDirectory |
|
10 | from IPython.utils.tempdir import NamedFileInTemporaryDirectory | |
11 | from IPython.utils.tempdir import TemporaryWorkingDirectory |
|
11 | from IPython.utils.tempdir import TemporaryWorkingDirectory | |
12 |
|
12 | |||
13 |
|
13 | |||
14 | def test_named_file_in_temporary_directory(): |
|
14 | def test_named_file_in_temporary_directory(): | |
15 | with NamedFileInTemporaryDirectory('filename') as file: |
|
15 | with NamedFileInTemporaryDirectory('filename') as file: | |
16 | name = file.name |
|
16 | name = file.name | |
17 | assert not file.closed |
|
17 | assert not file.closed | |
18 | assert Path(name).exists() |
|
18 | assert Path(name).exists() | |
19 | file.write(b'test') |
|
19 | file.write(b'test') | |
20 | assert file.closed |
|
20 | assert file.closed | |
21 | assert not Path(name).exists() |
|
21 | assert not Path(name).exists() | |
22 |
|
22 | |||
23 | def test_temporary_working_directory(): |
|
23 | def test_temporary_working_directory(): | |
24 | with TemporaryWorkingDirectory() as directory: |
|
24 | with TemporaryWorkingDirectory() as directory: | |
25 | directory_path = Path(directory) |
|
25 | directory_path = Path(directory).resolve() | |
26 | assert directory_path.exists() |
|
26 | assert directory_path.exists() | |
27 |
assert Path.cwd() == directory_path |
|
27 | assert Path.cwd().resolve() == directory_path | |
28 | assert not directory_path.exists() |
|
28 | assert not directory_path.exists() | |
29 |
assert Path.cwd() != directory_path |
|
29 | assert Path.cwd().resolve() != directory_path |
@@ -1,40 +1,28 | |||||
1 | build: false |
|
1 | build: false | |
2 | matrix: |
|
2 | matrix: | |
3 | fast_finish: true # immediately finish build once one of the jobs fails. |
|
3 | fast_finish: true # immediately finish build once one of the jobs fails. | |
4 |
|
4 | |||
5 | environment: |
|
5 | environment: | |
6 | global: |
|
6 | global: | |
7 | APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2022' |
|
7 | APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2022' | |
8 | COLUMNS: 120 # Appveyor web viwer window width is 130 chars |
|
8 | COLUMNS: 120 # Appveyor web viwer window width is 130 chars | |
9 |
|
9 | |||
10 | matrix: |
|
10 | matrix: | |
11 |
|
11 | |||
12 | - PYTHON: "C:\\Python310-x64" |
|
|||
13 | PYTHON_VERSION: "3.10.x" |
|
|||
14 | PYTHON_ARCH: "64" |
|
|||
15 |
|
||||
16 | - PYTHON: "C:\\Python37-x64" |
|
|||
17 | PYTHON_VERSION: "3.7.x" |
|
|||
18 | PYTHON_ARCH: "64" |
|
|||
19 |
|
||||
20 | - PYTHON: "C:\\Python38" |
|
12 | - PYTHON: "C:\\Python38" | |
21 | PYTHON_VERSION: "3.8.x" |
|
13 | PYTHON_VERSION: "3.8.x" | |
22 | PYTHON_ARCH: "32" |
|
14 | PYTHON_ARCH: "32" | |
23 |
|
15 | |||
24 | - PYTHON: "C:\\Python38-x64" |
|
|||
25 | PYTHON_VERSION: "3.8.x" |
|
|||
26 | PYTHON_ARCH: "64" |
|
|||
27 |
|
||||
28 | init: |
|
16 | init: | |
29 | - "ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH%" |
|
17 | - "ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH%" | |
30 |
|
18 | |||
31 | install: |
|
19 | install: | |
32 | - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" |
|
20 | - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" | |
33 | - python -m pip install --upgrade setuptools pip |
|
21 | - python -m pip install --upgrade setuptools pip | |
34 | - pip install pytest-cov |
|
22 | - pip install pytest-cov | |
35 | - pip install -e .[test_extra] |
|
23 | - pip install -e .[test_extra] | |
36 | test_script: |
|
24 | test_script: | |
37 | - pytest --color=yes -ra --cov --cov-report=xml |
|
25 | - pytest --color=yes -ra --cov --cov-report=xml | |
38 | on_finish: |
|
26 | on_finish: | |
39 | - curl -Os https://uploader.codecov.io/latest/windows/codecov.exe |
|
27 | - curl -Os https://uploader.codecov.io/latest/windows/codecov.exe | |
40 | - codecov -e PYTHON_VERSION,PYTHON_ARCH |
|
28 | - codecov -e PYTHON_VERSION,PYTHON_ARCH |
General Comments 0
You need to be logged in to leave comments.
Login now