Commit Graph

18 Commits

Author SHA1 Message Date
David Dalcino
173fbb9b6b Add suggestion on MemoryError to use external 7z 2021-10-29 11:08:15 -07:00
David Dalcino
cf5ca6e468 Add test for --noarchives flag 2021-10-20 19:21:22 -07:00
David Dalcino
d5213142a8 Fix misuse of disable_socket (#415)
In an earlier PR, I added calls to `disable_socket()` from
`pytest_socket` where I thought they were needed to prevent some tests
from accessing the network, in case they weren't monkeypatched properly.
Today, I discovered that `disable_socket()` disables sockets globally
for all tests, which means that the tests that use remote data cannot
run if they are executed after another test calls `disable_socket()`.

This change calls `disable_socket()` once from `conftest.py`, so that
no tests are allowed to use network data unless they are marked as ok
to use the network, with `@pytest.mark.enable_socket`. See example of
usage in `tests/test_connection.py`.

Changed return code for unexpected exceptions:

This allows us to write tests that can discover whether an unexpected
exception occurred just by checking the return code, rather than reading
stderr. This will allow us to write less friable tests that don't break
every time some insignificant output details change.

This change catches exceptions derived from Exception and
KeyboardInterrupt raised by `installer`, while run by multiple
processes, and propagates them back to earlier stack entries. This will
prevent any OSError and BrokenPipe exceptions that would otherwise be
raised when one process has an exception while the other processes are
still running.

This also handles the MemoryError exception we saw in #416, and offers
some suggestions for solving the issue.
2021-10-05 14:40:05 +09:00
David Dalcino
776ab6181f Propagate exceptions from run_installer()
This change catches exceptions derived from Exception and
KeyboardInterrupt raised by `installer`, while run by multiple
processes, and propagates them back to earlier stack entries. This will
prevent any OSError and BrokenPipe exceptions that would otherwise be
raised when one process has an exception while the other processes are
still running.

This also handles the MemoryError exception we saw in #416, and offers
some suggestions for solving the issue.
2021-10-02 18:26:03 -07:00
David Dalcino
a5bb2553ce Add improved error messages for missing archives 2021-09-20 12:46:47 -07:00
David Dalcino
7856631120 Add tests for new installer exceptions raised 2021-09-06 13:09:27 -07:00
David Dalcino
cfd4234877 Expect Cli.run not to exit on connection errors 2021-09-01 12:36:29 -07:00
David Dalcino
425421f0bb Add test to install missing modules
The previous tests only test the QtArchive classes; this test covers
what happens when invalid modules are passed to a Cli object.
2021-08-25 15:04:07 -07:00
David Dalcino
c3c22ded20 fix import order 2021-08-18 10:42:51 -07:00
David Dalcino
384950794a Add tests that install modules 2021-08-18 10:17:33 -07:00
David Dalcino
1c4f96736c Fix expected install directory for Qt 5.9 2021-08-11 12:05:43 -07:00
David Dalcino
a0222edcf8 Add unit tests for Qt 5.9 installation 2021-08-11 11:26:38 -07:00
Hiroshi Miura
4e6fe665ab Black/PEP8
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2021-08-06 08:12:13 +09:00
David Dalcino
bc2945687c Rename autoused fixture more appropriately 2021-08-04 15:47:40 -07:00
David Dalcino
ec99247bad Monkeypatch multiprocessing.Manager 2021-08-04 15:47:10 -07:00
David Dalcino
e94ee842bb Allow platform-dependent path separators 2021-08-04 15:46:23 -07:00
David Dalcino
c95516ed8e Remove re.Pattern type hint
In Python 3.6, `re.Pattern` does not exist, and using it as a type hint
causes the tests to fail. This change enables the tests to run on
Python 3.6.
2021-08-04 15:43:56 -07:00
David Dalcino
66f1231444 Add 'tests/test_install.py'
This change adds unit tests for the `aqt install` and `aqt install-qt`
commands, and establishes a pattern that can be extended for more
tests. This is intended to make it easier to increase test coverage of
parts of the codebase that are not yet covered by tests.

This uses the `pytest-socket` library to ensure that the tests do not
use any network IO. It also mocks `multiprocessing.get_context` to
prevent multiprocessing. This is necessary because multiprocessing
spawns child processes that have not been monkey-patched, which would
break the test.

These tests use py7zr to create mock 7z archives, which are installed
and patched in a temporary directory. The tests check the content
of the patched files and any output to stderr.
2021-08-03 16:06:47 -07:00