Commit Graph

41 Commits (3ba1625a99f489fdd2a16c0f50f425b468f37405)

Author SHA1 Message Date
Alex Willmer f162a8a7c5 Fix DjangoMixin test imports for setuptools >= 50.0 4 years ago
David Wilson bdf6f1b9a9 issue #590: rework ParentEnumerationMethod to recursively handle bad modules
In the worst case it will start with sys.path and resolve everything
from scratch.
5 years ago
David Wilson f1287e6e9a tests: Py3.x fix. 6 years ago
David Wilson 90105e2031 tests: Py3.x fix. 6 years ago
David Wilson 50cdf63c27 tests: Py3.x fix. 6 years ago
David Wilson 2f29f3e8e6 tests: rearrange test modules again, they're used in multiple places
They're back on sys.path.
6 years ago
David Wilson 2f68a5a660 module_finder_test: mask one more difference between unit2 vs. direct start 6 years ago
David Wilson c1db0d3858 issue #590: move example modules to module_finder/, fix/add tests 6 years ago
David Wilson 263f530496 tests: fix fallout from 36fb318adf5c56e729296c3efce84f4dd75ced4e 6 years ago
David Wilson 0e193c223c issue #508: master: minify all Mitogen/ansible_mitogen sources.
Minify-safe files are marked with a magical "# !mitogen: minify_safe"
comment anywhere in the file, which activates the minifier. The result
is naturally cached by ModuleResponder, therefore lru_cache is gone too.

Given:

    import os, mitogen
    @mitogen.main()
    def main(router):
        c = router.ssh(hostname='k3')
        c.call(os.getpid)
        router.sudo(via=c)

SSH footprint drops from 56.2 KiB to 42.75 KiB (-23.9%)
Ansible "shell: hostname" drops 149.26 KiB to 117.42 KiB (-21.3%)
6 years ago
David Wilson 3435f24e8d issue #479: ModuleFinder special case for __main__ on Py3.x. 6 years ago
David Wilson 767331d76f issue #477: disable Django parts of module_finder_test on 2.4. 6 years ago
David Wilson d4897d37bb issue #477: ModuleFinder now returns Unicode module names. 6 years ago
David Wilson 06415bb720 issue #310: fix test failures, teach old import method new tricks
- don't try anything unless something really lives in sys.modules by
  that name
- non-ASCII files are possible
- the unimportable thing might be an extension module, we don't want
  that
6 years ago
David Wilson 6af1a64cce master: handle crazy non-modules in sys.modules again; closes #310. 6 years ago
Alex Willmer 9fbcb67665 Update pytz to 2018.05 (needed by babel 2.6.0)
On Ubuntu 18.04 (others not tested) installing the dev requirements
fails with the following error

babel 2.6.0 has requirement pytz>=0a, but you'll have pytz 2012d which
is incompatible.

Despite the comment in dev_requirements.txt pytz-2012d is not the most
recent version to support Python 2.6. In fact the latest release of pytz
supports Python 2.6.
6 years ago
David Wilson 7697861011 tests: skip one test that triggers bug in ancient vendered six.py 6 years ago
David Wilson c141dd10ec master: fix resolve_relpath()
looks like this was just as broken on 2.x, and suddenly we're
finding a bunch more legit Django deps. It seems anywhere
absolute_import appeared in 2.x, we skipped some imports.
6 years ago
David Wilson b0404bef40 tests: fix get_module_via_* encoding issues 6 years ago
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.
6 years ago
David Wilson cec564654e issue #275: tests: fix module_finder_test for 2.6. 6 years ago
David Wilson 4be8afa3d3 issue #275: tests: fix test_simple for 2.6. 6 years ago
David Wilson f7d2eace08 tests: importer fixes 7 years ago
David Wilson 2a4157723a tests: fix breakage from moving is_stdlib_name() 7 years ago
Alex Willmer 1bc32adad4 Issue #160: Cache minimize_source()
Before

```
python tests/bench/local.py
0 120.245933533
1 119.300842285
2 118.355035782
3 123.839855194
```

After

```
python tests/bench/local.py
0 66.3640499115
1 65.9508705139
2 72.4799633026
3 65.7958984375
```
7 years ago
Alex Willmer 491355548d tests: Fix typo in ResolveRelPathTest 7 years ago
Alex Willmer ef35d55523 tests: Remove jinja2/markupsafe modules from FindRelatedTest
Not sure how they got there, but Django doesn't use Jinja without
explicit configuration.
7 years ago
Alex Willmer eee312a57e tests: Fix expected values FindRelatedTest for Django 1.11.4 7 years ago
Alex Willmer 4424bfbb7a tests: Add new FindRelatedImportsTest 7 years ago
Alex Willmer 9e43f5e6ba tests: Remove module under search from expected results
This matches a tweak made in 8765f761c9
7 years ago
Alex Willmer 0f9bfc1e21 tests: Rename FindRelatedImportsTest -> FindRelatedTest 7 years ago
Alex Willmer fa0f390d4d FIx syntax error in FindRelatedImportsTest.test_django_db_models 7 years ago
David Wilson 219718740b Move django test script into permanent test 7 years ago
Alex Willmer 7e01c5bed5 Import and use unittest2 without aliasing it 7 years ago
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.
7 years ago
Alex Willmer 17da6e9998 Use unittest2 in all tests
This allows using features such as TestCase,assertIsInstance on Python
2.6 and earlier.
7 years ago
Alex Willmer 3831ac360f 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.
7 years ago
Alex Willmer 026669aa93 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.
7 years ago
David Wilson 828f60351b 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.
7 years ago
David Wilson 15bf0f54e2 Beginnings of module_finder_test 7 years ago
David Wilson 2454dcc990 core: loosen assertion to allow fakessh_test to succeed. 7 years ago