twisted.internet.test.test_inotify.INotifyTests(unittest.TestCase)
class documentationtwisted.internet.test.test_inotify
(View In Hierarchy)
Define all the tests for the basic functionality exposed by inotify.INotify
.
Method | setUp | Undocumented |
Method | test_initializationErrors | inotify.INotify
emits a RuntimeError when initialized in an environment that
doesn't support inotify as we expect it. |
Method | test_access | Reading from a file in a monitored directory sends an
inotify.IN_ACCESS event to the callback. |
Method | test_modify | Writing to a file in a monitored directory sends an
inotify.IN_MODIFY event to the callback. |
Method | test_attrib | Changing the metadata of a file in a monitored directory sends an
inotify.IN_ATTRIB event to the callback. |
Method | test_closeWrite | Closing a file which was open for writing in a monitored directory sends
an inotify.IN_CLOSE_WRITE event to the callback. |
Method | test_closeNoWrite | Closing a file which was open for reading but not writing in a monitored
directory sends an inotify.IN_CLOSE_NOWRITE event to the
callback. |
Method | test_open | Opening a file in a monitored directory sends an
inotify.IN_OPEN event to the callback. |
Method | test_movedFrom | Moving a file out of a monitored directory sends an
inotify.IN_MOVED_FROM event to the callback. |
Method | test_movedTo | Moving a file into a monitored directory sends an
inotify.IN_MOVED_TO event to the callback. |
Method | test_create | Creating a file in a monitored directory sends an
inotify.IN_CREATE event to the callback. |
Method | test_delete | Deleting a file in a monitored directory sends an
inotify.IN_DELETE event to the callback. |
Method | test_deleteSelf | Deleting the monitored directory itself sends an
inotify.IN_DELETE_SELF event to the callback. |
Method | test_moveSelf | Renaming the monitored directory itself sends an
inotify.IN_MOVE_SELF event to the callback. |
Method | test_simpleSubdirectoryAutoAdd | inotify.INotify
when initialized with autoAdd==True adds also adds the created
subdirectories to the watchlist. |
Method | test_simpleDeleteDirectory | inotify.INotify
removes a directory from the watchlist when it's removed from the
filesystem. |
Method | test_ignoreDirectory | inotify.INotify.ignore
removes a directory from the watchlist |
Method | test_humanReadableMask | inotify.humaReadableMask translates all the possible event
masks to a human readable string. |
Method | test_recursiveWatch | inotify.INotify.watch
with recursive==True will add all the subdirectories under the given path
to the watchlist. |
Method | test_connectionLostError | inotify.INotify.connectionLost
if there's a problem while closing the fd shouldn't raise the exception but
should log the error |
Method | test_noAutoAddSubdirectory | inotify.INotify.watch
with autoAdd==False will stop inotify from watching subdirectories created
under the watched one. |
Method | test_seriesOfWatchAndIgnore | inotify.INotify
will watch a filepath for events even if the same path is repeatedly
added/removed/re-added to the watchpoints. |
Method | test_ignoreFilePath | inotify.INotify
will ignore a filepath after it has been removed from the watch list. |
Method | test_ignoreNonWatchedFile | inotify.INotify
will raise KeyError if a non-watched filepath is ignored. |
Method | test_complexSubdirectoryAutoAdd | inotify.INotify
with autoAdd==True for a watched path generates events for every file or
directory already present in a newly created subdirectory under the watched
one. |
Method | _notificationTest | Test notification from some filesystem operation. |
Inherited from TestCase:
Instance Variable | timeout | A real number of seconds. If set, the test will raise an error if it takes
longer than timeout seconds. If not set,
util.DEFAULT_TIMEOUT_DURATION is used. |
Method | __init__ | Construct an asynchronous test case for methodName . |
Method | assertFailure | Fail if deferred does not errback with one of
expectedFailures . Returns the original Deferred with callbacks
added. You will need to return this Deferred from your test case. |
Method | __call__ | Run the test. Should always do exactly the same thing as run(). |
Method | deferSetUp | Undocumented |
Method | deferTestMethod | Undocumented |
Method | deferTearDown | Undocumented |
Method | deferRunCleanups | Run any scheduled cleanups and report errors (if any to the result object. |
Method | addCleanup | Extend the base cleanup feature with support for cleanup functions which return Deferreds. |
Method | getSuppress | Undocumented |
Method | getTimeout | No summary |
Method | _run | Run a single method, either a test method or fixture. |
Method | _ebDeferSetUp | Undocumented |
Method | _cbDeferTestMethod | Undocumented |
Method | _ebDeferTestMethod | Undocumented |
Method | _ebDeferTearDown | Undocumented |
Method | _cbDeferRunCleanups | Undocumented |
Method | _cleanUp | Undocumented |
Method | _classCleanUp | Undocumented |
Method | _makeReactorMethod | Create a method which wraps the reactor method name . The
new method issues a deprecation warning and calls the original. |
Method | _deprecateReactor | Deprecate iterate , crash and stop
on reactor . That is, each method is wrapped in a function that
issues a deprecation warning, then calls the original. |
Method | _undeprecateReactor | Restore the deprecated reactor methods. Undoes what _deprecateReactor
did. |
Method | _runCleanups | Run the cleanups added with addCleanup
in order. |
Method | _runFixturesAndTest | Really run setUp , the test method, and
tearDown . Any of these may return defer.Deferred s.
After they complete, do some reactor cleanup. |
Method | _wait | Take a Deferred that only ever callbacks. Block until it happens. |
Inherited from SynchronousTestCase (via TestCase):
Instance Variable | failureException | An exception class, defaulting to FailTest . If the test method
raises this exception, it will be reported as a failure, rather than an
exception. All of the assertion methods raise this if the assertion fails. |
Instance Variable | skip | None
or a string explaining why this test is to be skipped. If defined, the test
will not be run. Instead, it will be reported to the result object as
'skipped' (if the TestResult supports skipping). |
Instance Variable | todo | None ,
a string or a tuple of (errors, reason) where
errors is either an exception class or an iterable of
exception classes, and reason is a string. See Todo or makeTodo for
more information. |
Instance Variable | suppress | None
or a list of tuples of (args, kwargs) to be passed to
warnings.filterwarnings . Use these to suppress warnings raised
in a test. Useful for testing deprecated code. See also util.suppress . |
Method | __eq__ | No summary |
Method | __ne__ | Undocumented |
Method | __hash__ | Undocumented |
Method | shortDescription | Undocumented |
Method | getSkip | No summary |
Method | getTodo | No summary |
Method | runTest | If no methodName argument is passed to the constructor, run
will treat this method as the thing with the actual test inside. |
Method | run | Run the test case, storing the results in result . |
Method | patch | Monkey patch an object for the duration of the test. |
Method | flushLoggedErrors | Remove stored errors received from the log. |
Method | flushWarnings | Remove stored warnings from the list of captured warnings and return them. |
Method | callDeprecated | Call a function that should have been deprecated at a specific version and in favor of a specific alternative, and assert that it was thusly deprecated. |
Method | mktemp | Create a new path name which can be used for a new file or directory. |
Method | _getSuppress | No summary |
Method | _getSkipReason | Return the reason to use for skipping a test method. |
Method | _installObserver | Undocumented |
Method | _removeObserver | Undocumented |
Inherited from _Assertions (via TestCase, SynchronousTestCase):
Method | fail | Absolutely fail the test. Do not pass go, do not collect $200. |
Method | assertFalse | Fail the test if condition evaluates to True. |
Method | assertTrue | Fail the test if condition evaluates to False. |
Method | assertRaises | Fail the test unless calling the function f with the given
args and kwargs raises exception .
The failure will report the traceback and call stack of the unexpected
exception. |
Method | assertEqual | Fail the test if first and second are not
equal. |
Method | assertIs | Fail the test if first is not second . This is
an obect-identity-equality test, not an object equality (i.e.
__eq__ ) test. |
Method | assertIsNot | Fail the test if first is second . This is an
obect-identity-equality test, not an object equality (i.e.
__eq__ ) test. |
Method | assertNotEqual | Fail the test if first == second . |
Method | assertIn | Fail the test if containee is not found in
container . |
Method | assertNotIn | Fail the test if containee is found in
container . |
Method | assertNotAlmostEqual | Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero. |
Method | assertAlmostEqual | Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero. |
Method | assertApproximates | Fail if first - second >
tolerance |
Method | assertSubstring | Fail if substring does not exist within
astring . |
Method | assertNotSubstring | Fail if astring contains substring . |
Method | assertWarns | Fail if the given function doesn't generate the specified warning when called. It calls the function, checks the warning, and forwards the result of the function if everything is fine. |
Method | assertIsInstance | Fail if instance is not an instance of the given class or
of one of the given classes. |
Method | assertNotIsInstance | Fail if instance is an instance of the given class or of
one of the given classes. |
Method | successResultOf | Return the current success result of deferred or raise
self.failureException . |
Method | failureResultOf | Return the current failure result of deferred or raise
self.failureException . |
Method | assertNoResult | Assert that deferred does not have a result at this
point. |
Method | assertRegex | Fail the test if a regexp search of text
fails. |
inotify.INotify
emits a RuntimeError
when initialized in an environment that
doesn't support inotify as we expect it.
We just try to raise an exception for every possible case in the for
loop in inotify.INotify._inotify__init__
.
Test notification from some filesystem operation.
Parameters | mask | The event mask to use when setting up the watch. |
operation | A function which will be called with the name of a file in the watched directory and which should trigger the event. | |
expectedPath | Optionally, the name of the path which is expected to come back in the
notification event; this will also be passed to operation
(primarily useful when the operation is being done to the directory itself,
not a file in it). | |
Returns | A Deferred
which fires successfully when the expected event has been received or fails
otherwise. |
Reading from a file in a monitored directory sends an
inotify.IN_ACCESS
event to the callback.
Writing to a file in a monitored directory sends an
inotify.IN_MODIFY
event to the callback.
Changing the metadata of a file in a monitored directory sends an
inotify.IN_ATTRIB
event to the callback.
Closing a file which was open for writing in a monitored directory sends
an inotify.IN_CLOSE_WRITE
event to the callback.
Closing a file which was open for reading but not writing in a monitored
directory sends an inotify.IN_CLOSE_NOWRITE
event to the
callback.
Opening a file in a monitored directory sends an
inotify.IN_OPEN
event to the callback.
Moving a file out of a monitored directory sends an
inotify.IN_MOVED_FROM
event to the callback.
Moving a file into a monitored directory sends an
inotify.IN_MOVED_TO
event to the callback.
Creating a file in a monitored directory sends an
inotify.IN_CREATE
event to the callback.
Deleting a file in a monitored directory sends an
inotify.IN_DELETE
event to the callback.
Deleting the monitored directory itself sends an
inotify.IN_DELETE_SELF
event to the callback.
Renaming the monitored directory itself sends an
inotify.IN_MOVE_SELF
event to the callback.
inotify.INotify
when initialized with autoAdd==True adds also adds the created
subdirectories to the watchlist.
inotify.INotify
removes a directory from the watchlist when it's removed from the
filesystem.
inotify.humaReadableMask
translates all the possible event
masks to a human readable string.
inotify.INotify.watch
with recursive==True will add all the subdirectories under the given path
to the watchlist.
inotify.INotify.connectionLost
if there's a problem while closing the fd shouldn't raise the exception but
should log the error
inotify.INotify.watch
with autoAdd==False will stop inotify from watching subdirectories created
under the watched one.
inotify.INotify
will watch a filepath for events even if the same path is repeatedly
added/removed/re-added to the watchpoints.
inotify.INotify
will ignore a filepath after it has been removed from the watch list.
inotify.INotify
will raise KeyError if a non-watched filepath is ignored.
inotify.INotify
with autoAdd==True for a watched path generates events for every file or
directory already present in a newly created subdirectory under the watched
one.
This tests that we solve a race condition in inotify even though we may generate duplicate events.