Commit Graph

90 Commits

Author SHA1 Message Date
David Wilson a53e85ff69 tests: stubs for future whitelist/blacklist tests. 2018-02-16 08:19:23 +05:45
dw feacb2bd40
Merge pull request #80 from moreati/sins-of-the-parent
Fix/split test_master tests following split of mitogen.master -> mitogen.parent
2018-02-15 05:26:24 +05:45
dw d708405126
Merge pull request #82 from moreati/imported-via-the-scenic-route
Fix TypeError while initiliazing ImporterMixin
2018-02-15 05:26:05 +05:45
Alex Willmer 83c0111b51 Fix TypeError while initiliazing ImporterMixin
Since f44356af32 mitogen.core.Importer()
takes a Router instance.
2018-02-14 23:04:10 +00:00
Alex Willmer 49b6c586e3 FIx syntax error in FindRelatedImportsTest.test_django_db_models 2018-02-14 22:54:00 +00:00
Alex Willmer 5ba2db0794 Split IterReadTest & WriteAllTest into test_parent
This matches their respective functions under test, which now reside in
mitogen.parent.
2018-02-14 22:48:31 +00:00
Alex Willmer f114c5951b Adjust unittest for master -> parent split
Tests should now match changes in
4d31300dd0
2018-02-14 22:40:09 +00:00
David Wilson 8ef87bea6a select: clean up API. 2018-02-14 19:45:22 +05:45
David Wilson e01632c431 Move django test script into permanent test 2018-02-12 10:30:11 +05:45
David Wilson 85934d101f tests: ensure strace is available in the docker image..
..and enable privileged=True since that's needed for ptrace()
2017-12-05 02:01:58 +05:30
David Wilson 43fae4414a Replace nasty print statements in six_brokenpkg. 2017-11-19 19:25:53 +05:30
dw 5e552e597c
Merge pull request #65 from moreati/unittest2-this-time-its-personal
Use unittest2 and specific assertX methods
2017-11-12 19:54:23 +05:30
Alex Willmer 110eba05ce Import and use unittest2 without aliasing it 2017-11-12 12:42:27 +00:00
Alex Willmer 7473addfd2 Replace all calls to file() with open()
Although these are synonyms in Python 2.x, when using MyPy to typecheck
code use of file() causes spurious errors.

This commit also serves as one small step to Python 3.x compatibility,
since 3.x removes the file() builtin.
2017-11-11 23:36:54 +00:00
Alex Willmer 81a77a453a Use specific TestCase assertions throughout tests
e.g. assert x == y -> self.assertEqual(x, y);
self.assertTrue(isinstance(x, y)) -> self.assertIsInstance(x, y)

These specific methods give more useful errors in the case of a test
failure.
2017-11-11 23:08:08 +00:00
Alex Willmer fdccf6a891 Replace custom assertContains() with unitest2 assertIn() 2017-11-11 23:02:26 +00:00
Alex Willmer 9351a44784 Use unittest2 in all tests
This allows using features such as TestCase,assertIsInstance on Python
2.6 and earlier.
2017-11-11 22:59:38 +00:00
R W H Bricheno 8fb0234176 Prevent MacOS exception on shutdown of closed socket. 2017-10-30 12:07:10 +00:00
R W H Bricheno 5a9c9d7101 Fix getting the directory path on Mac OS X. 2017-10-30 10:36:40 +00:00
Alex Willmer 29529c9a5c tests: Fix GetModuleViaPkgutilTest fetching .pyc
On my laptop (Ubuntu 17.10, Python 2.7.14 in a virtualenv),
`test_regular_mod` fails with

```
AssertionError: "\nimport sys\n\n\ndef say_hi():\n    print 'hi'\n" !=
'\x03\xf3\r\n\xbbW\xd5Yc\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00@\x00\x00\x00s\x19\x00\x00\x00d\x00\x00d\x01\x00l\x00\x00Z\x00\x00d\x02\x00\x84\x00\x00Z\x01\x00d\x01\x00S(\x03\x00\x00\x00i\xff\xff\xff\xffNc\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00C\x00\x00\x00s\t\x00\x00\x00d\x01\x00GHd\x00\x00S(\x02\x00\x00\x00Nt\x02\x00\x00\x00hi(\x00\x00\x00\x00(\x00\x00\x00\x00(\x00\x00\x00\x00(\x00\x00\x00\x00sF\x00\x00\x00/home/alex/src/mitogen/tests/data/module_finder_testmod/regular_mod.pyt\x06\x00\x00\x00say_hi\x05\x00\x00\x00s\x02\x00\x00\x00\x00\x01(\x02\x00\x00\x00t\x03\x00\x00\x00sysR\x01\x00\x00\x00(\x00\x00\x00\x00(\x00\x00\x00\x00(\x00\x00\x00\x00sF\x00\x00\x00/home/alex/src/mitogen/tests/data/module_finder_testmod/regular_mod.pyt\x08\x00\x00\x00<module>\x02\x00\x00\x00s\x02\x00\x00\x00\x0c\x03'
```

`__file__` contains the path of the compiled `.pyc`, not the `.py`
source file.
2017-10-20 19:48:26 +01:00
David Wilson f1660d5011 tests: initial first_stage_test. 2017-10-16 20:51:23 +05:30
David Wilson 2e8ed68609 Merge branch 'pr/50' 2017-10-16 17:16:29 +05:30
Alex Willmer fe2bf7111a ssh_test: Correct hostname in SShTest.test_stream_name()
I presume that `u1704` is a relic of a bygone container/host.
2017-10-15 20:33:59 +01:00
Alex Willmer a0fbe99be0 testlib: Wait for sshd before running tests
On Ubuntu 17.10 something (probably Docker) appears to be accepting
connections, before sshd is fully ready. This results in a race
condition, and hence connection errors for the first few tests (2-3 on
my laptop).

testlib.wait_for_port() checks not only that the port can be connected
to, but also something resembling the sshd banner is sent.

Fixes #51
2017-10-15 20:31:10 +01:00
Alex Willmer cae6989932 testlib: Auto negotiate Docker API version
Ubuntu 17.04 provides Docker 1.12.6, which has API version 1.24.
`dev_requirements.txt` specifies the docker-py 2.5.1, which by default
requests API version 1.30.

Hence when the SSH unit tests try to run the container specified in
`DockerizedSshDaemon` an error occurs

```
APIError: 400 Client Error: Bad Request ("client is newer than server
(client API version: 1.30, server API version: 1.24)")
```
2017-10-09 22:05:02 +01:00
David Wilson 492777f61b tests: stop responder_test spamming the logs 2017-10-08 19:14:52 +05:30
David Wilson 9e884d3d8b tests: stop fakessh spamming the logs 2017-10-08 19:14:21 +05:30
David Wilson c83d86f050 importer: Delete _get_module_via_parent entirely
Can't figure out what it's supposed to do any more, and can't find a
version of Ansible before August 2016 (when I wrote that code) that
seems to need it.

Add some more mitigations to avoid sending dylibs.
2017-10-08 16:33:04 +05:30
David Wilson 397ff50a58 Try to be compatible with older Docker daemons; (hopefully) closes #46 2017-10-05 05:03:57 +05:30
David Wilson 8439e889ed core: More robust shutdown
Now there is a separate SHUTDOWN message that relies only on being
received by the broker thread, the main thread can be hung horribly and
the process will still eventually receive a SIGTERM.
2017-10-03 16:35:12 +05:30
David Wilson 1784f3c83a Add test that hangs the main thread during shutdown. 2017-10-03 16:09:35 +05:30
David Wilson fa9def91f2 Implement test_aborted_on_local_context_disconnect 2017-10-03 15:54:55 +05:30
David Wilson e3b51de6b1 Handle docker running on localhost. 2017-10-02 15:22:00 +05:30
David Wilson d7c15859bf Let utils_test run directly too. 2017-10-02 14:36:36 +05:30
David Wilson eac5daf28d Fix select_test failure, remove crap old timing_test. 2017-10-02 14:35:27 +05:30
David Wilson 291a44dc34 Remove proxy_test (duplicates sudo_test) 2017-10-02 13:56:33 +05:30
David Wilson 1f73c32d4c frameworkize nested_test. 2017-10-02 13:56:02 +05:30
David Wilson eb6afee514 Beginnings of module_finder_test 2017-10-02 13:54:01 +05:30
David Wilson fccf1b1cab Fix importer_test constructor signature. 2017-10-01 15:30:43 +05:30
David Wilson e6795a5c43 core: loosen assertion to allow fakessh_test to succeed. 2017-10-01 15:29:04 +05:30
David Wilson 2ed39c411f Allow call_function_test to succeed depite testlib import. 2017-09-30 20:58:05 +05:30
David Wilson 2659cf0ae0 Use enhanced assertRaises in call_function_test.py. 2017-09-30 20:57:14 +05:30
David Wilson b0e13fefdd Fix 2 call_function_test failures. 2017-09-30 15:09:05 +05:30
David Wilson 909937cc21 Simple scan_code_imports test. 2017-09-30 13:55:41 +05:30
David Wilson f57a12b3f9 Fix context naming for sudo and via=. 2017-09-29 16:04:09 +05:30
David Wilson 1a48e37981 Allow running responder_test with unittest. 2017-09-28 14:37:27 +05:30
David Wilson 839a1cbeb1 receiver: only permit one notify callback
There is no point spamming a list for every function call, there is no
use case where multiple notify callbacks would be useful.
2017-09-28 10:58:57 +05:30
David Wilson 031c0f3cf4 issue #20: TestCase subclass with a nicer assertRaises 2017-09-27 13:56:19 +05:30
David Wilson 186d823600 issue #20: tests and fixes for mitogen.master.Select(). 2017-09-27 13:47:14 +05:30
David Wilson 0db472c97b Fix up importer_test. 2017-09-25 05:20:50 +05:30