Commit Graph

21 Commits

Author SHA1 Message Date
Alexandre Detiste fe54b0ac3f prefer newer unittest.mock from the standad library 2024-04-04 15:23:06 +01:00
Alex Willmer 5ad3d14ceb mitogen: Support PEP 451 ModuleSpec API, required for Python 3.12
importlib.machinery.ModuleSpec and find_spec() were introduced in Python 3.4
under PEP 451. They replace the find_module() API of PEP 302, which was
deprecated from Python 3.4. They were removed in Python 3.12 along with the
imp module.

This change adds support for the PEP 451 APIs. Mitogen should no longer import
imp on Python versions that support ModuleSpec. Tests have been added to cover
the new APIs.

CI jobs have been added to cover Python 3.x on macOS.

Refs #1033
Co-authored-by: Witold Baryluk <witold.baryluk@gmail.com>
2024-03-17 14:57:57 +00:00
Alex Willmer 18c89de5a9 Remove unused module imports 2022-04-23 10:01:06 +01:00
Alex Willmer caa20be43e tests: Use TestCase.assertEqual()
assertEquals() is deperecated in unittest
2022-04-21 19:23:43 +01:00
Alex Willmer a8317c2393 tests: Remove unittest2, use stdlib unittest
unittest2 is incomplatible with Python 3.10
2022-04-20 17:54:12 +01:00
David Wilson 8f940e2ccb issue #590: teach importer to handle self-replacing modules 2019-06-02 13:08:44 +01:00
David Wilson 30d933b299 issue #477: remove unused pytest bits from importer_test. 2019-01-26 20:27:01 +00:00
David Wilson e9706a4a09 issue #477: _update_linecache() must append newlines. 2019-01-24 16:59:24 +00:00
David Wilson cbcd8267d1 tests: must decode() zlib result for 3.x. 2018-07-07 14:55:47 +01:00
David Wilson 410016ff47 Initial Python 3.x port work.
* ansible: use unicode_literals everywhere since it only needs to be
  compatible back to 2.6.
* compat/collections.py: delete this entirely and rip out the parts of
  functools that require it.
* Introduce serializable Kwargs dict subclass that translates keys to
  Unicode on instantiation.
* enable_debug_logging() must set _v/_vv globals.
* cStringIO does not exist in 3.x.
* Treat IOLogger and LogForwarder input as latin-1.
* Avoid ResourceWarnings in first stage by explicitly closing fps.
* Fix preamble_size.py syntax errors.
2018-07-07 14:55:47 +01:00
David Wilson 03fcf057dd tests: just call log_to_file() from testlib
Now we can run test.sh with MITOGEN_LOG_LEVEL=debug and things just
work.
2018-03-29 07:25:11 +00:00
David Wilson 23e279b617 tests: get import_test limping back to health. 2018-03-22 05:07:31 +05:45
Alex Willmer 4b373c421b core: Standardise type of Importer.whitelist
This seemed a reasonable streamlining, but I'm happy to be overruled.
2018-03-19 21:58:31 +05:45
Alex Willmer 8338caa419 tests: Add mitogen.core.is_blacklisted_import() tests
These test the current behviour, which may not be exactly the intended
behaviour. Refs #98
2018-03-19 21:58:31 +05:45
Alex Willmer 9ccff0f5d1 Fix TypeError while initiliazing ImporterMixin
Since f44356af32 mitogen.core.Importer()
takes a Router instance.
2018-03-19 21:58:29 +05:45
Alex Willmer 7e01c5bed5 Import and use unittest2 without aliasing it 2018-03-19 21:58:28 +05:45
Alex Willmer e8e023ce59 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.
2018-03-19 21:58:28 +05:45
Alex Willmer 17da6e9998 Use unittest2 in all tests
This allows using features such as TestCase,assertIsInstance on Python
2.6 and earlier.
2018-03-19 21:58:27 +05:45
David Wilson d17af194b5 Fix importer_test constructor signature. 2018-03-19 21:35:37 +05:45
David Wilson ced6d8e404 Fix up importer_test. 2018-03-19 21:35:36 +05:45
David Wilson e7ff6259a3 Initial commit. 2018-03-19 21:35:13 +05:45