summaryrefslogtreecommitdiff
path: root/fixtures/tests
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #50 from stephenfin/warnings-filterJelmer Vernooij2022-10-191-1/+58
|\ | | | | Add WarningsFilter fixture
| * Add WarningsFilter fixtureStephen Finucane2022-10-191-1/+58
| | | | | | | | | | | | | | | | | | This has enough users around OpenStack to justify adding it to 'fixtures' proper. It's intentionally dumb, since the main purpose of this is to avoid people calling `resetwarnings` in their variant of the fixture, as that clears *all* filters including those we don't control. Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* | tests: Replace hardcoded list of test modulesStephen Finucane2022-10-191-14/+7
|/ | | | | | Avoid this being an issue again the future. Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* tests: Run 'warnings' testsStephen Finucane2022-10-192-3/+16
| | | | | | | | These were never added to the list of filtered modules, meaning they never actually ran. Correct that and fix the failures, which were caused by DeprecationWarning being disabled by default in Python 3.2 onwards. Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* Support Popen's process_group argument from Python 3.11Michał Górny2022-05-221-0/+14
|
* Update classmethod expectations (again) for Python 3.11Michał Górny2022-05-221-1/+2
| | | | | | | It seems that the classmethod behavior in Python 3.11.0b1 is back to the one found in Python 3.8. Adjust the test expectations again. This time around, we expect the "old-new" behavior in CPython 3.9 and 3.10 only.
* Revert to the previous classmethod expectations for PyPy3.9Michał Górny2022-04-281-3/+6
| | | | | | | | Commit fe83067 has changed TestMonkeyPatch to account for changes in classmethod handling in CPython 3.9. Unfortunately, this broke the tests on PyPy3.9. Revert to the old expectations when using PyPy. Fixes #64
* tests: Validate function signature of FakePopenStephen Finucane2022-02-111-2/+48
| | | | | | Make sure we maintain compatibility as subprocess.Popen changes. Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* Support all Popen arguments up to Python 3.10Colin Watson2022-02-091-15/+42
| | | | Fixes #53.
* Failing test for compatibility problem with Python 3.7Jürgen Gmach2022-02-091-0/+14
|
* Mark README as rSTStephen Finucane2022-01-281-1/+1
| | | | | | It's valid rST and renders nicely in GitHub's UI this way. Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* Merge pull request #42 from gibizer/masterJelmer Vernooij2021-03-091-0/+9
|\ | | | | Add possibility to reset the FakeLogger
| * Add possibility to reset the FakeLoggerBalazs Gibizer2019-05-021-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | A long test case might emit extensive logs that subunit does not really handle well [1]. So it is useful to reset the logs stored in the fixture at certain points in the test execution[2]. To be able to do that this patch adds reset_output() call to the FakeLogger. [1] https://bugs.launchpad.net/nova/+bug/1813147 [2] https://review.opendev.org/#/c/656844
* | Remove six and other Python 2 handling codeStephen Finucane2021-02-254-47/+34
| | | | | | | | Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* | Fix tests on Python 3.9Stephen Finucane2021-02-251-13/+35
| | | | | | | | | | | | | | I'm not entirely sure this is correct, but it's the only thing I can find related to changes in classmethod in Python 3.9. Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* | Remove unused imports and variableshugovk2018-06-044-10/+7
| |
* | Drop support for EOL Python 2.6hugovk2018-06-041-10/+4
|/
* Add missing APIs to FakeProcess, making it match Popen (LP #1373224)Free Ekanayaka2016-11-091-0/+32
|
* Fixup the MonkeyPatch patch.Robert Collins2016-05-201-13/+14
| | | | | | | | - docs. - cleanup patches of boundmethods to not leave cruft behind. - NEWS entry. Sem-Ver: api-break
* Tweak the new tests for consistencyRobert Collins2016-05-191-52/+34
|
* Update the semantics on _fixtures.MonkeyPatchAndrew Laski2016-05-191-8/+365
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A previous change added some logic so that when monkeypatching a staticmethod the old_value was restored as a staticmethod. There was an issue where the determination of whether or not a method should be static was incorrectly checking the new function not the one to be replaced. That caused an unintended side-effect that in order to patch an instance method of a class the new function needed to be an instance method of a class. This change now reworks the semantics of MonkeyPatch to address that issue and at the same time be explicit about how it should work in a large number of different cases. The rule is simple and provides great flexibility. Given a callable bar to be patched on to foo bar will be called with any bound arguments first and then arguments of foo appended. This is easier to visualize. Given: class C(object): @classmethod def foo(cls, arg): pass class D(object): @classmethod def bar(cls, tgtcls, arg): pass def baz(cls, arg): pass MonkeyPatch('...C.foo', D.bar) will result in C.foo(1) calling bar like bar(D, C, 1) because cls on bar was already bound to D when patching. And MonkeyPatch('...C.foo', baz) will result in baz being called with baz(C, 1).
* MonkeyPatch staticmethodAndrew Laski2016-04-071-1/+3
| | | | | | | | | | | | | | | | | | | | | | | In Python setattr(Class, name, func) automatically converts a function into an instancemethod. To keep type(Class.func) as function, staticmethod(func) must be applied explicitly. This was previously fixed for Python 2 when cleaning up the patched function but Python 3 needs the same handling. When patching a function it was being converted to an instancemethod for both Python 2 and 3 and this has now been fixed. This is a breaking change as it was previously acceptable to patch a staticmethod with an instancemethod. The test for this case was updated to correctly check both cases. The patched function is called as both Class.function() and Class().function(), and then called again after the cleanup has occurred resetting the function to its original state. The Class().function() check is important because the method does not become bound until the class it is defined on is instantiated. Sem-Ver: api-break
* Fix "propagate" spelling everywhereJonathan Lange2015-11-032-3/+3
|
* FakeLogger: Mis-formatted log messages will raise ExceptionJohn L. Villalovos2015-10-071-0/+6
| | | | | | | | | | | | | | | When using the FakeLogger, have mis-formatted logging messages raise an exception. Normally when using the logging module, mis-formatted logging messages will not raise an exception. Instead the exception will be printed but not raised. Change this behavior so that mis-formatted log messages can be caught during unit-testing. Closes-Bug: #1503049 Change-Id: I8d3e94d131289300ae020eb1d63306489e986335
* Use mock in preference to unittest.mock.Robert Collins2015-10-081-1/+1
| | | | | | If folk have installed both, they probably want the bugfixes from the rolling backport vs the potentially stale Python 3.3 or 3.4 etc version.
* Handle BaseException resource leaks as well.Robert Collins2015-06-301-0/+15
| | | | | The change to handle resource leaks incorrectly ignored BaseException - e.g. KeyboardInterrupt.
* Deal with resource leaks during setUp.Robert Collins2015-06-291-3/+73
| | | | | | | | Fixture.setUp should no longer be overridden in subclasses. Instead override _setUp. This permits the Fixture base class to detect failures during _setUp and trigger any registered cleanups, attach any details to the failure exception and propogate that to callers. (Robert Collins, #1456361, #1456353)
* Fine tune the mock patch.Robert Collins2015-06-221-4/+2
|
* Add a new mockpatch fixtureJulien Danjou2015-06-222-0/+75
| | | | | This fixture provides an easy usage for mock (unittest.mock in Python 3).
* Add a warnings module capture fixureJoshua Harlow2015-05-041-0/+49
| | | | | | | | | | Capturing the warnings module output (which is typically used for deprecating code or functions or modules) is quite useful and is a frequent operation that can be required to perform. So provide a fixture that is similar (but not the same) as the warnings ``catch_warnings`` context manager that can be used to gather all warnings emitted and allows people to later analyze them to ensure they are as they expect.
* Fixed test performance on Python 3.5.Robert Collins2015-03-271-4/+4
| | | | | PEP 475 led to ``time.sleep()`` not being interrupted when a received signal handler eats the signal (rather than raising an exception). (Robert Collins)
* allow the specification of a custom log formatterSean Dague2015-03-261-0/+24
| | | | | | | | | | When working on OpenStack in tree functional test things like the context information is extremely useful to have access to. This relies on using custom log formatter, which currently can't be done in fixtures. The creates an additional optional parameter for FakeLogger to specify this.
* Add support for datefmt in FakeLoggerSean Dague2014-09-261-0/+10
| | | | | | | | | | | | | | | The logging fixture is extremely useful to be used a temp buffer for collecting log messages into a buffer, and only decide if we're going to emit them after some event in the future (like the failure or success of some future criteria). However, in it's current form we are not given access to the datefmt variable of the underlying Formatter, which means we always end up with the default python time string for %(asctime), which looks incorrectly localized many places. This merely adds the ability to pass the datefmt param through to the Formatter. Signed-off-by: Sean Dague <sean@dague.net>
* Migrate to git and pbr.Robert Collins2014-09-2517-0/+1473
No functional changes.