summaryrefslogtreecommitdiff
path: root/test.py
Commit message (Collapse)AuthorAgeFilesLines
* Introduced the more natural reading assertIsNotInstance().Gustavo Niemeyer2010-09-181-0/+4
|
* Added assertRaisesRegexp() to MockerTestCase. It works similarly toGustavo Niemeyer2010-09-181-0/+104
| | | | | the version in Python 2.7 and 3.2, except it will also return the error found. It also works as a context manager for with: statements.
* - Implemented support for assertRaises() as a context manager, as inGustavo Niemeyer2010-09-181-0/+103
| | | | | | Python 2.7 and 3.2. - Implemented assertIsInstance() and assertIsNotInstance() as well. - Updated NEWS file.
* Tasks now have a may_run_user_code() method, which is used for tasks whichGustavo Niemeyer2010-09-181-16/+109
| | | | | | can potentially run unknown code or throw unknown exceptions. This is used by the Event.run() method to prevent running unknown logic when the event as a whole is already known to have failed.
* Minor cleanups in the test suite.Gustavo Niemeyer2010-09-181-9/+3
|
* mocker.call() now supports a with_object argument. If True, the calledGustavo Niemeyer2010-07-291-0/+62
| | | | | function will receive the patched or proxied object so that its state may be used or verified in checks.
* MockerTestCase.assertRaises() will now return the exception raised,Gustavo Niemeyer2010-06-201-0/+37
|\ | | | | | | | | allowing further inspection of the raised exception (implemented by Thomas Hervé) (#299930).
| * Return exception in failUnlessRaises, test it.Thomas Hervé2008-11-191-0/+37
| |
* | Fixed support for MockerTestCase.addCleanup() in Python 2.3,Gustavo Niemeyer2010-06-201-0/+38
| | | | | | | | by Anders F Björklund (#528657).
* | Unwrap bound methods on replace() and proxy(), as suggestedGustavo Niemeyer2010-06-201-0/+12
| | | | | | | | by James Henstridge (#270782).
* | Use the more reliable expect() automatically with MockerTestCase.Gustavo Niemeyer2010-06-201-1/+6
| |
* | Implemented Expect helper, which allows creating a new expect()Gustavo Niemeyer2010-06-201-1/+8
| | | | | | | | | | | | "function" with an explicitly provided Mocker instance. This helps in cases where the expression can't result in a Mock instance (e.g. expect(iter(mock))) (#196388).
* | Fixed support for Python 2.6. Mocking of iterators was broken inGustavo Niemeyer2010-06-191-1/+20
| | | | | | | | | | certain cases because, even though that's *not* documented, Python tries to use __length_hint__ in some cases.
* | __nonzero__ should necessarily return a boolean value, so transform MockGustavo Niemeyer2010-03-151-0/+4
| | | | | | | | results into True.
* | Merged 328990-mocker-hides-exception branch from Duncan McGreggor. ThisGustavo Niemeyer2009-02-131-0/+15
|\ \ | |/ |/| | | | | | | ensures that the raised AttributeError exception on a patched object actually exposes the real problem rather than an internal Mocker exception.
| * - Added a new unit test to check for a bug in mocker where the originalDuncan McGreggor2009-02-131-0/+14
|/ | | | | attribute gets swallowed by a subsequent exception check. - Added a fix for the bug.
* Moved the __mocker_mock__ cleaning up test from Patcher into itsGustavo Niemeyer2008-07-011-2/+8
| | | | own method around the Mocker.patch() tests.
* Merging branch from Thomas which changes Mocker.patch() to use theGustavo Niemeyer2008-07-011-0/+2
|\ | | | | | | | | patcher when setting __mocker_mock__, rather than setting it in a persistent way.
| * Use the version that passes the landscape tests. Add a test for one of the fix.Thomas Hervé2008-06-301-0/+2
| |
* | Prevent the MockerTestCase base from leaving the mocker in replay modeGustavo Niemeyer2008-07-011-0/+27
|/ | | | | | while the base class run() method runs, since this might have additional logic which touches mocked content (time.time() was one case). Thanks to Thomas for the initial debugging.
* When cleaning up on MockerTestCase, use reset() rather than restore(),Gustavo Niemeyer2008-03-281-0/+11
| | | | | so that the same test case instance may be run more than once (like Trial does).
* Fixed patching of objects which define __getattr__.0.10.1Gustavo Niemeyer2007-12-111-1/+49
|
* Orderer() is now implemented based on may_run() instead of matches().Gustavo Niemeyer2007-12-091-15/+47
| | | | | If the event is run with may_run() False, a nice assertion error is raised with a nice debugging message. :-)
* Introduced {Task,Event}.may_run() to improve replaying orderingGustavo Niemeyer2007-12-091-15/+75
| | | | | logic. Now events which have may_run() true will be run before events which don't.
* When the expression executed isn't exactly the same as theGustavo Niemeyer2007-12-091-0/+26
| | | | | recorded events (e.g. when parameter matchers are used), show in the error message the real expression run, to aid in debugging.
* Fixed problem when requesting order on similar expressions. TheGustavo Niemeyer2007-12-091-6/+20
| | | | second expression might not be accepted.
* MockerTestCase.makeFile() with content=None (the default) nowGustavo Niemeyer2007-12-071-1/+6
| | | | | consistently returns an unexistent temporary filename which is properly cleaned up if created.
* New 'path' option to MockerTestCase.makeFile() and makeDir(),Gustavo Niemeyer2007-12-051-4/+28
| | | | which allows setting the full target path with a single option.
* New MATCH() argument matcher, which allows using a functionGustavo Niemeyer2007-12-051-2/+14
| | | | to match an argument generically. E.g. MATCH(lambda x: x > 10)
* Implemented MockerTestCase.addCleanup(). It allows one toGustavo Niemeyer2007-12-051-9/+18
| | | | | register cleanup functions to be called after the test is complete.
* Now when a spec is provided (or with proxy/replace/patch) theGustavo Niemeyer2007-12-041-0/+18
| | | | | existence of the real method is checked even if the mocked method doesn't have to execute (e.g. due to count(0)).
* MockerTestCase now verifies if the mocker is put in replayGustavo Niemeyer2007-12-041-0/+20
| | | | mode in cases where events were recorded.
* Implemented support for Deferred results as understood byGustavo Niemeyer2007-12-041-0/+41
| | | | | Twisted Trial's TestCase, so that coexistence by multiple inheritance is possible and trivial.
* In MockerTestCase's constructor, copy attributes from the original methodGustavo Niemeyer2007-12-041-0/+9
| | | | into the wrapper.
* - Added support for Python 2.3 (patch by Phillip J. Eby).Gustavo Niemeyer2007-11-241-42/+54
| | | | | - Added MockerTestCase.assert{True,False} aliases, so that they're available even in Python 2.3.
* Introduced automatic test coverage verification, and covered theGustavo Niemeyer2007-11-231-1/+82
| | | | few statements which were not being passed through.
* Now Mocker.mock()/proxy()/replace() accept a 'count' keywordGustavo Niemeyer2007-11-221-1/+26
| | | | | parameter, which if set to False, the default behavior of allowing expressions just once is disabled.
* In recording mode, mock.__class__ will now return Mock, and notGustavo Niemeyer2007-11-221-4/+20
| | | | | | record the action. This allows Mocker to be used in interactive environments which inspect the result's type, such as in iPython (reported by Alex Dante).
* Added MockerTestCase.assert[Not]{Starts,Ends}With().Gustavo Niemeyer2007-11-171-0/+120
|
* Added MockerTestCase.assertMethodsMatch(). It will verify if allGustavo Niemeyer2007-11-171-0/+62
| | | | | | | public methods found in the class passed as the first argument are also present in the class passed as the second argument, and that they accept the same arguments. This is useful to verify if a fake or stub class have the same API as the real class being simulated.
* Implemented state resetting on replay() for RunCounter and Orderer.Gustavo Niemeyer2007-11-131-0/+36
|
* When using an unexistent import path for Mocker.proxy(), raise anGustavo Niemeyer2007-11-131-0/+3
| | | | | ImportError on the base module, rather than using the actual string as the object (#162315).
* Mocker.on_restore() removed. Restore isn't performed if replay()Gustavo Niemeyer2007-11-121-10/+0
| | | | | isn't called, and that may not be obvious, so a hook won't be exposed for now.
* New MockerTestCase.makeFile() and .makeDir() helpers. They offerGustavo Niemeyer2007-11-121-1/+95
| | | | | easy creation of temporary files/directories with certainty of removal after tests finish running.
* Moved "string proxying" logic out of replace() and into proxy().Gustavo Niemeyer2007-11-111-0/+16
|
* Fixed SpecChecker to not break with callables not supported byGustavo Niemeyer2007-11-111-0/+23
| | | | getargspec (e.g. builtin functions).
* Implemented delitem action kind.Gustavo Niemeyer2007-11-111-0/+18
|
* - Implemented MockerTestCase.Gustavo Niemeyer2007-11-111-32/+338
| | | | | - Renamed special argument SAME to IS, and added IN. - Implemented Mocker.on_restore().
* Implemented Mocker.generate().Gustavo Niemeyer2007-11-041-0/+10
|
* Implemented len, iter and nonzero action kinds.Gustavo Niemeyer2007-11-041-7/+112
|