code
stringlengths
26
870k
docstring
stringlengths
1
65.6k
func_name
stringlengths
1
194
language
stringclasses
1 value
repo
stringlengths
8
68
path
stringlengths
5
194
url
stringlengths
46
254
license
stringclasses
4 values
def test_errorInParentWithTruncatedUnicode(self): """ When the child writes a non-ASCII error message to the status pipe during daemonization, and that message is too longer, the parent writes the repr of the truncated message to C{stderr} and exits with a non-zero status code. """ truncatedMessage = b'1 RuntimeError: ' + b'\\u2022' * 14 # the escape sequence will appear to be escaped twice, because # we're getting the repr reportedMessage = "b'RuntimeError: {}'".format(r'\\u2022' * 14) self.assertErrorInParentBehavior( readData=truncatedMessage, errorMessage=( "An error has occurred: {}\n" "Please look at log file for more information.\n".format( reportedMessage) ), mockOSActions=[ ('chdir', '.'), ('umask', 0o077), ('fork', True), ('read', -1, 100), ('exit', 1), ('unlink', 'twistd.pid'), ], )
When the child writes a non-ASCII error message to the status pipe during daemonization, and that message is too longer, the parent writes the repr of the truncated message to C{stderr} and exits with a non-zero status code.
test_errorInParentWithTruncatedUnicode
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
MIT
def test_errorMessageTruncated(self): """ If an error occurs during daemonization and its message is too long, it's truncated by the child. """ self.assertErrorWritten( raised="x" * 200, reported=b'1 RuntimeError: ' + b'x' * 84)
If an error occurs during daemonization and its message is too long, it's truncated by the child.
test_errorMessageTruncated
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
MIT
def test_unicodeErrorMessageTruncated(self): """ If an error occurs during daemonization and its message is unicode and too long, it's truncated by the child, even if this splits a unicode escape sequence. """ self.assertErrorWritten( raised=u"\u2022" * 30, reported=b'1 RuntimeError: ' + b'\\u2022' * 14, )
If an error occurs during daemonization and its message is unicode and too long, it's truncated by the child, even if this splits a unicode escape sequence.
test_unicodeErrorMessageTruncated
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
MIT
def test_hooksCalled(self): """ C{daemonize} indeed calls L{IReactorDaemonize.beforeDaemonize} and L{IReactorDaemonize.afterDaemonize} if the reactor implements L{IReactorDaemonize}. """ reactor = FakeDaemonizingReactor() self.runner.daemonize(reactor) self.assertTrue(reactor._beforeDaemonizeCalled) self.assertTrue(reactor._afterDaemonizeCalled)
C{daemonize} indeed calls L{IReactorDaemonize.beforeDaemonize} and L{IReactorDaemonize.afterDaemonize} if the reactor implements L{IReactorDaemonize}.
test_hooksCalled
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
MIT
def test_hooksNotCalled(self): """ C{daemonize} does NOT call L{IReactorDaemonize.beforeDaemonize} or L{IReactorDaemonize.afterDaemonize} if the reactor does NOT implement L{IReactorDaemonize}. """ reactor = FakeNonDaemonizingReactor() self.runner.daemonize(reactor) self.assertFalse(reactor._beforeDaemonizeCalled) self.assertFalse(reactor._afterDaemonizeCalled)
C{daemonize} does NOT call L{IReactorDaemonize.beforeDaemonize} or L{IReactorDaemonize.afterDaemonize} if the reactor does NOT implement L{IReactorDaemonize}.
test_hooksNotCalled
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
MIT
def preApplication(self): """ Does nothing. """
Does nothing.
preApplication
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
MIT
def postApplication(self): """ Instantiate a SignalCapturingMemoryReactor and start it in the runner. """ reactor = SignalCapturingMemoryReactor() reactor._exitSignal = self._signalValue self.startReactor(reactor, sys.stdout, sys.stderr)
Instantiate a SignalCapturingMemoryReactor and start it in the runner.
postApplication
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
MIT
def stubApplicationRunnerFactory(config): """ Create a StubApplicationRunnerWithSignal using a reactor that implements _ISupportsExitSignalCapturing and whose _exitSignal attribute is set to signum. @param config: The runner configuration, platform dependent. @type config: L{twisted.scripts.twistd.ServerOptions} @return: A runner to use for the test. @rtype: twisted.test.test_twistd.StubApplicationRunnerWithSignal """ runner = StubApplicationRunnerWithSignal(config) runner._signalValue = signum return runner
Create a StubApplicationRunnerWithSignal using a reactor that implements _ISupportsExitSignalCapturing and whose _exitSignal attribute is set to signum. @param config: The runner configuration, platform dependent. @type config: L{twisted.scripts.twistd.ServerOptions} @return: A runner to use for the test. @rtype: twisted.test.test_twistd.StubApplicationRunnerWithSignal
stubApplicationRunnerFactoryCreator.stubApplicationRunnerFactory
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
MIT
def stubApplicationRunnerFactoryCreator(signum): """ Create a factory function to instantiate a StubApplicationRunnerWithSignal that will report signum as the captured signal.. @param signum: The integer signal number or None @type signum: C{int} or C{None} @return: A factory function to create stub runners. @rtype: stubApplicationRunnerFactory """ def stubApplicationRunnerFactory(config): """ Create a StubApplicationRunnerWithSignal using a reactor that implements _ISupportsExitSignalCapturing and whose _exitSignal attribute is set to signum. @param config: The runner configuration, platform dependent. @type config: L{twisted.scripts.twistd.ServerOptions} @return: A runner to use for the test. @rtype: twisted.test.test_twistd.StubApplicationRunnerWithSignal """ runner = StubApplicationRunnerWithSignal(config) runner._signalValue = signum return runner return stubApplicationRunnerFactory
Create a factory function to instantiate a StubApplicationRunnerWithSignal that will report signum as the captured signal.. @param signum: The integer signal number or None @type signum: C{int} or C{None} @return: A factory function to create stub runners. @rtype: stubApplicationRunnerFactory
stubApplicationRunnerFactoryCreator
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
MIT
def fakeKill(pid, sig): """ Fake method to capture arguments passed to os.kill. @param pid: The pid of the process being killed. @param sig: The signal sent to the process. """ self.fakeKillArgs[0] = pid self.fakeKillArgs[1] = sig
Fake method to capture arguments passed to os.kill. @param pid: The pid of the process being killed. @param sig: The signal sent to the process.
setUp.fakeKill
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
MIT
def setUp(self): """ Set up the server options and a fake for use by test cases. """ self.config = twistd.ServerOptions() self.config.loadedPlugins = {'test_command': MockServiceMaker()} self.config.subOptions = object() self.config.subCommand = 'test_command' self.fakeKillArgs = [None, None] def fakeKill(pid, sig): """ Fake method to capture arguments passed to os.kill. @param pid: The pid of the process being killed. @param sig: The signal sent to the process. """ self.fakeKillArgs[0] = pid self.fakeKillArgs[1] = sig self.patch(os, 'kill', fakeKill)
Set up the server options and a fake for use by test cases.
setUp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
MIT
def test_exitWithSignal(self): """ exitWithSignal replaces the existing signal handler with the default handler and sends the replaced signal to the current process. """ fakeSignalArgs = [None, None] def fake_signal(sig, handler): fakeSignalArgs[0] = sig fakeSignalArgs[1] = handler self.patch(signal, 'signal', fake_signal) app._exitWithSignal(signal.SIGINT) self.assertEquals(fakeSignalArgs[0], signal.SIGINT) self.assertEquals(fakeSignalArgs[1], signal.SIG_DFL) self.assertEquals(self.fakeKillArgs[0], os.getpid()) self.assertEquals(self.fakeKillArgs[1], signal.SIGINT)
exitWithSignal replaces the existing signal handler with the default handler and sends the replaced signal to the current process.
test_exitWithSignal
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
MIT
def test_normalExit(self): """ _exitWithSignal is not called if the runner does not exit with a signal. """ self.patch( twistd, '_SomeApplicationRunner', stubApplicationRunnerFactoryCreator(None) ) twistd.runApp(self.config) self.assertIsNone(self.fakeKillArgs[0]) self.assertIsNone(self.fakeKillArgs[1])
_exitWithSignal is not called if the runner does not exit with a signal.
test_normalExit
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
MIT
def test_runnerExitsWithSignal(self): """ _exitWithSignal is called when the runner exits with a signal. """ self.patch( twistd, '_SomeApplicationRunner', stubApplicationRunnerFactoryCreator(signal.SIGINT) ) twistd.runApp(self.config) self.assertEquals(self.fakeKillArgs[0], os.getpid()) self.assertEquals(self.fakeKillArgs[1], signal.SIGINT)
_exitWithSignal is called when the runner exits with a signal.
test_runnerExitsWithSignal
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py
MIT
def testTriggerPause(self): """Make sure I say \"when.\"""" # Pause the proxy so data sent to it builds up in its buffer. self.proxy.pauseProducing() self.assertFalse(self.parentProducer.paused, "don't pause yet") self.proxy.write("x" * 51) self.assertFalse(self.parentProducer.paused, "don't pause yet") self.proxy.write("x" * 51) self.assertTrue(self.parentProducer.paused)
Make sure I say \"when.\
testTriggerPause
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_pcp.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_pcp.py
MIT
def testTriggerResume(self): """Make sure I resumeProducing when my buffer empties.""" self.proxy.pauseProducing() self.proxy.write("x" * 102) self.assertTrue(self.parentProducer.paused, "should be paused") self.proxy.resumeProducing() # Resuming should have emptied my buffer, so I should tell my # parent to resume too. self.assertFalse(self.parentProducer.paused, "Producer should have resumed.") self.assertFalse(self.proxy.producerPaused)
Make sure I resumeProducing when my buffer empties.
testTriggerResume
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_pcp.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_pcp.py
MIT
def setUp(self): """ Create a file with two users. """ self.filename = self.mktemp() f = FilePath(self.filename) f.setContent(b':'.join(self.usernamePassword)) self.options = Options()
Create a file with two users.
setUp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ftp_options.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ftp_options.py
MIT
def test_passwordfileDeprecation(self): """ The C{--password-file} option will emit a warning stating that said option is deprecated. """ self.callDeprecated( versions.Version("Twisted", 11, 1, 0), self.options.opt_password_file, self.filename)
The C{--password-file} option will emit a warning stating that said option is deprecated.
test_passwordfileDeprecation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ftp_options.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ftp_options.py
MIT
def test_authAdded(self): """ The C{--auth} command-line option will add a checker to the list of checkers """ numCheckers = len(self.options['credCheckers']) self.options.parseOptions(['--auth', 'file:' + self.filename]) self.assertEqual(len(self.options['credCheckers']), numCheckers + 1)
The C{--auth} command-line option will add a checker to the list of checkers
test_authAdded
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ftp_options.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ftp_options.py
MIT
def test_authFailure(self): """ The checker created by the C{--auth} command-line option returns a L{Deferred} that fails with L{UnauthorizedLogin} when presented with credentials that are unknown to that checker. """ self.options.parseOptions(['--auth', 'file:' + self.filename]) checker = self.options['credCheckers'][-1] invalid = credentials.UsernamePassword(self.usernamePassword[0], 'fake') return (checker.requestAvatarId(invalid) .addCallbacks( lambda ignore: self.fail("Wrong password should raise error"), lambda err: err.trap(error.UnauthorizedLogin)))
The checker created by the C{--auth} command-line option returns a L{Deferred} that fails with L{UnauthorizedLogin} when presented with credentials that are unknown to that checker.
test_authFailure
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ftp_options.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ftp_options.py
MIT
def test_authSuccess(self): """ The checker created by the C{--auth} command-line option returns a L{Deferred} that returns the avatar id when presented with credentials that are known to that checker. """ self.options.parseOptions(['--auth', 'file:' + self.filename]) checker = self.options['credCheckers'][-1] correct = credentials.UsernamePassword(*self.usernamePassword) return checker.requestAvatarId(correct).addCallback( lambda username: self.assertEqual(username, correct.username) )
The checker created by the C{--auth} command-line option returns a L{Deferred} that returns the avatar id when presented with credentials that are known to that checker.
test_authSuccess
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ftp_options.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ftp_options.py
MIT
def connectionLost(self, reason): """ Check that C{reason} is a L{Failure} wrapping a L{ConnectionDone} instance and stop the reactor. If C{reason} is wrong for some reason, log something about that in C{self.errorLogFile} and make sure the process exits with a non-zero status. """ try: try: reason.trap(ConnectionDone) except: log.err(None, "Problem with reason passed to connectionLost") self.exitCode = 1 finally: reactor.stop()
Check that C{reason} is a L{Failure} wrapping a L{ConnectionDone} instance and stop the reactor. If C{reason} is wrong for some reason, log something about that in C{self.errorLogFile} and make sure the process exits with a non-zero status.
connectionLost
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/stdio_test_loseconn.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/stdio_test_loseconn.py
MIT
def test_setNonBlocking(self): """ L{fdesc.setNonBlocking} sets a file description to non-blocking. """ r, w = os.pipe() self.addCleanup(os.close, r) self.addCleanup(os.close, w) self.assertFalse(fcntl.fcntl(r, fcntl.F_GETFL) & os.O_NONBLOCK) fdesc.setNonBlocking(r) self.assertTrue(fcntl.fcntl(r, fcntl.F_GETFL) & os.O_NONBLOCK)
L{fdesc.setNonBlocking} sets a file description to non-blocking.
test_setNonBlocking
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def test_setBlocking(self): """ L{fdesc.setBlocking} sets a file description to blocking. """ r, w = os.pipe() self.addCleanup(os.close, r) self.addCleanup(os.close, w) fdesc.setNonBlocking(r) fdesc.setBlocking(r) self.assertFalse(fcntl.fcntl(r, fcntl.F_GETFL) & os.O_NONBLOCK)
L{fdesc.setBlocking} sets a file description to blocking.
test_setBlocking
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def setUp(self): """ Create a non-blocking pipe that can be used in tests. """ self.r, self.w = os.pipe() fdesc.setNonBlocking(self.r) fdesc.setNonBlocking(self.w)
Create a non-blocking pipe that can be used in tests.
setUp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def tearDown(self): """ Close pipes. """ try: os.close(self.w) except OSError: pass try: os.close(self.r) except OSError: pass
Close pipes.
tearDown
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def write(self, d): """ Write data to the pipe. """ return fdesc.writeToFD(self.w, d)
Write data to the pipe.
write
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def read(self): """ Read data from the pipe. """ l = [] res = fdesc.readFromFD(self.r, l.append) if res is None: if l: return l[0] else: return b"" else: return res
Read data from the pipe.
read
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def test_writeAndRead(self): """ Test that the number of bytes L{fdesc.writeToFD} reports as written with its return value are seen by L{fdesc.readFromFD}. """ n = self.write(b"hello") self.assertTrue(n > 0) s = self.read() self.assertEqual(len(s), n) self.assertEqual(b"hello"[:n], s)
Test that the number of bytes L{fdesc.writeToFD} reports as written with its return value are seen by L{fdesc.readFromFD}.
test_writeAndRead
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def test_writeAndReadLarge(self): """ Similar to L{test_writeAndRead}, but use a much larger string to verify the behavior for that case. """ orig = b"0123456879" * 10000 written = self.write(orig) self.assertTrue(written > 0) result = [] resultlength = 0 i = 0 while resultlength < written or i < 50: result.append(self.read()) resultlength += len(result[-1]) # Increment a counter to be sure we'll exit at some point i += 1 result = b"".join(result) self.assertEqual(len(result), written) self.assertEqual(orig[:written], result)
Similar to L{test_writeAndRead}, but use a much larger string to verify the behavior for that case.
test_writeAndReadLarge
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def test_readFromEmpty(self): """ Verify that reading from a file descriptor with no data does not raise an exception and does not result in the callback function being called. """ l = [] result = fdesc.readFromFD(self.r, l.append) self.assertEqual(l, []) self.assertIsNone(result)
Verify that reading from a file descriptor with no data does not raise an exception and does not result in the callback function being called.
test_readFromEmpty
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def test_readFromCleanClose(self): """ Test that using L{fdesc.readFromFD} on a cleanly closed file descriptor returns a connection done indicator. """ os.close(self.w) self.assertEqual(self.read(), fdesc.CONNECTION_DONE)
Test that using L{fdesc.readFromFD} on a cleanly closed file descriptor returns a connection done indicator.
test_readFromCleanClose
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def test_writeToClosed(self): """ Verify that writing with L{fdesc.writeToFD} when the read end is closed results in a connection lost indicator. """ os.close(self.r) self.assertEqual(self.write(b"s"), fdesc.CONNECTION_LOST)
Verify that writing with L{fdesc.writeToFD} when the read end is closed results in a connection lost indicator.
test_writeToClosed
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def test_readFromInvalid(self): """ Verify that reading with L{fdesc.readFromFD} when the read end is closed results in a connection lost indicator. """ os.close(self.r) self.assertEqual(self.read(), fdesc.CONNECTION_LOST)
Verify that reading with L{fdesc.readFromFD} when the read end is closed results in a connection lost indicator.
test_readFromInvalid
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def test_writeToInvalid(self): """ Verify that writing with L{fdesc.writeToFD} when the write end is closed results in a connection lost indicator. """ os.close(self.w) self.assertEqual(self.write(b"s"), fdesc.CONNECTION_LOST)
Verify that writing with L{fdesc.writeToFD} when the write end is closed results in a connection lost indicator.
test_writeToInvalid
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def test_writeErrors(self): """ Test error path for L{fdesc.writeTod}. """ oldOsWrite = os.write def eagainWrite(fd, data): err = OSError() err.errno = errno.EAGAIN raise err os.write = eagainWrite try: self.assertEqual(self.write(b"s"), 0) finally: os.write = oldOsWrite def eintrWrite(fd, data): err = OSError() err.errno = errno.EINTR raise err os.write = eintrWrite try: self.assertEqual(self.write(b"s"), 0) finally: os.write = oldOsWrite
Test error path for L{fdesc.writeTod}.
test_writeErrors
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def test_setCloseOnExec(self): """ A file descriptor passed to L{fdesc._setCloseOnExec} is not inherited by a new process image created with one of the exec family of functions. """ with open(self.mktemp(), 'wb') as fObj: fdesc._setCloseOnExec(fObj.fileno()) status = self._execWithFileDescriptor(fObj) self.assertTrue(os.WIFEXITED(status)) self.assertEqual(os.WEXITSTATUS(status), 0)
A file descriptor passed to L{fdesc._setCloseOnExec} is not inherited by a new process image created with one of the exec family of functions.
test_setCloseOnExec
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def test_unsetCloseOnExec(self): """ A file descriptor passed to L{fdesc._unsetCloseOnExec} is inherited by a new process image created with one of the exec family of functions. """ with open(self.mktemp(), 'wb') as fObj: fdesc._setCloseOnExec(fObj.fileno()) fdesc._unsetCloseOnExec(fObj.fileno()) status = self._execWithFileDescriptor(fObj) self.assertTrue(os.WIFEXITED(status)) self.assertEqual(os.WEXITSTATUS(status), 20)
A file descriptor passed to L{fdesc._unsetCloseOnExec} is inherited by a new process image created with one of the exec family of functions.
test_unsetCloseOnExec
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_fdesc.py
MIT
def mktemp(self): """ Return a temporary path, encoded as bytes. """ return TestCase.mktemp(self).encode("utf-8")
Return a temporary path, encoded as bytes.
mktemp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_verifyObject(self): """ Instances of the path type being tested provide L{IFilePath}. """ self.assertTrue(verifyObject(filepath.IFilePath, self.path))
Instances of the path type being tested provide L{IFilePath}.
test_verifyObject
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_segmentsFromPositive(self): """ Verify that the segments between two paths are correctly identified. """ self.assertEqual( self.path.child(b"a").child(b"b").child(b"c").segmentsFrom(self.path), [b"a", b"b", b"c"])
Verify that the segments between two paths are correctly identified.
test_segmentsFromPositive
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_segmentsFromNegative(self): """ Verify that segmentsFrom notices when the ancestor isn't an ancestor. """ self.assertRaises( ValueError, self.path.child(b"a").child(b"b").child(b"c").segmentsFrom, self.path.child(b"d").child(b"c").child(b"e"))
Verify that segmentsFrom notices when the ancestor isn't an ancestor.
test_segmentsFromNegative
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_walk(self): """ Verify that walking the path gives the same result as the known file hierarchy. """ x = [foo.path for foo in self.path.walk()] self.assertEqual(set(x), set(self.all))
Verify that walking the path gives the same result as the known file hierarchy.
test_walk
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_parents(self): """ L{FilePath.parents()} should return an iterator of every ancestor of the L{FilePath} in question. """ L = [] pathobj = self.path.child(b"a").child(b"b").child(b"c") fullpath = pathobj.path lastpath = fullpath thispath = os.path.dirname(fullpath) while lastpath != self.root.path: L.append(thispath) lastpath = thispath thispath = os.path.dirname(thispath) self.assertEqual([x.path for x in pathobj.parents()], L)
L{FilePath.parents()} should return an iterator of every ancestor of the L{FilePath} in question.
test_parents
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_validSubdir(self): """ Verify that a valid subdirectory will show up as a directory, but not as a file, not as a symlink, and be listable. """ sub1 = self.path.child(b'sub1') self.assertTrue(sub1.exists(), "This directory does exist.") self.assertTrue(sub1.isdir(), "It's a directory.") self.assertFalse(sub1.isfile(), "It's a directory.") self.assertFalse(sub1.islink(), "It's a directory.") self.assertEqual(sub1.listdir(), [b'file2'])
Verify that a valid subdirectory will show up as a directory, but not as a file, not as a symlink, and be listable.
test_validSubdir
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_invalidSubdir(self): """ Verify that a subdirectory that doesn't exist is reported as such. """ sub2 = self.path.child(b'sub2') self.assertFalse(sub2.exists(), "This directory does not exist.")
Verify that a subdirectory that doesn't exist is reported as such.
test_invalidSubdir
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_validFiles(self): """ Make sure that we can read existent non-empty files. """ f1 = self.path.child(b'file1') with f1.open() as f: self.assertEqual(f.read(), self.f1content) f2 = self.path.child(b'sub1').child(b'file2') with f2.open() as f: self.assertEqual(f.read(), self.f2content)
Make sure that we can read existent non-empty files.
test_validFiles
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_multipleChildSegments(self): """ C{fp.descendant([a, b, c])} returns the same L{FilePath} as is returned by C{fp.child(a).child(b).child(c)}. """ multiple = self.path.descendant([b'a', b'b', b'c']) single = self.path.child(b'a').child(b'b').child(b'c') self.assertEqual(multiple, single)
C{fp.descendant([a, b, c])} returns the same L{FilePath} as is returned by C{fp.child(a).child(b).child(c)}.
test_multipleChildSegments
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_dictionaryKeys(self): """ Verify that path instances are usable as dictionary keys. """ f1 = self.path.child(b'file1') f1prime = self.path.child(b'file1') f2 = self.path.child(b'file2') dictoid = {} dictoid[f1] = 3 dictoid[f1prime] = 4 self.assertEqual(dictoid[f1], 4) self.assertEqual(list(dictoid.keys()), [f1]) self.assertIs(list(dictoid.keys())[0], f1) self.assertIsNot(list(dictoid.keys())[0], f1prime) # sanity check dictoid[f2] = 5 self.assertEqual(dictoid[f2], 5) self.assertEqual(len(dictoid), 2)
Verify that path instances are usable as dictionary keys.
test_dictionaryKeys
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_dictionaryKeyWithString(self): """ Verify that path instances are usable as dictionary keys which do not clash with their string counterparts. """ f1 = self.path.child(b'file1') dictoid = {f1: 'hello'} dictoid[f1.path] = 'goodbye' self.assertEqual(len(dictoid), 2)
Verify that path instances are usable as dictionary keys which do not clash with their string counterparts.
test_dictionaryKeyWithString
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_childrenNonexistentError(self): """ Verify that children raises the appropriate exception for non-existent directories. """ self.assertRaises(filepath.UnlistableError, self.path.child(b'not real').children)
Verify that children raises the appropriate exception for non-existent directories.
test_childrenNonexistentError
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_childrenNotDirectoryError(self): """ Verify that listdir raises the appropriate exception for attempting to list a file rather than a directory. """ self.assertRaises(filepath.UnlistableError, self.path.child(b'file1').children)
Verify that listdir raises the appropriate exception for attempting to list a file rather than a directory.
test_childrenNotDirectoryError
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_newTimesAreFloats(self): """ Verify that all times returned from the various new time functions are ints (and hopefully therefore 'high precision'). """ for p in self.path, self.path.child(b'file1'): self.assertEqual(type(p.getAccessTime()), float) self.assertEqual(type(p.getModificationTime()), float) self.assertEqual(type(p.getStatusChangeTime()), float)
Verify that all times returned from the various new time functions are ints (and hopefully therefore 'high precision').
test_newTimesAreFloats
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_oldTimesAreInts(self): """ Verify that all times returned from the various time functions are integers, for compatibility. """ for p in self.path, self.path.child(b'file1'): self.assertEqual(type(p.getatime()), int) self.assertEqual(type(p.getmtime()), int) self.assertEqual(type(p.getctime()), int)
Verify that all times returned from the various time functions are integers, for compatibility.
test_oldTimesAreInts
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def listdir(self): """ @raise WindowsError: always. """ if _PY3: # For Python 3.3 and higher, WindowsError is an alias for OSError. # The first argument to the OSError constructor is errno, and the fourth # argument is winerror. # For further details, refer to: # https://docs.python.org/3/library/exceptions.html#OSError # # On Windows, if winerror is set in the constructor, # the errno value in the constructor is ignored, and OSError internally # maps the winerror value to an errno value. raise WindowsError( None, "A directory's validness was called into question", self.path, ERROR_DIRECTORY) else: raise WindowsError( ERROR_DIRECTORY, "A directory's validness was called into question")
@raise WindowsError: always.
listdir
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_windowsErrorExcept(self): """ Verify that when a WindowsError is raised from listdir, catching WindowsError works. """ fwp = FakeWindowsPath(self.mktemp()) self.assertRaises(filepath.UnlistableError, fwp.children) self.assertRaises(WindowsError, fwp.children)
Verify that when a WindowsError is raised from listdir, catching WindowsError works.
test_windowsErrorExcept
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_alwaysCatchOSError(self): """ Verify that in the normal case where a directory does not exist, we will get an OSError. """ fp = filepath.FilePath(self.mktemp()) self.assertRaises(OSError, fp.children)
Verify that in the normal case where a directory does not exist, we will get an OSError.
test_alwaysCatchOSError
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_keepOriginalAttributes(self): """ Verify that the Unlistable exception raised will preserve the attributes of the previously-raised exception. """ fp = filepath.FilePath(self.mktemp()) ose = self.assertRaises(OSError, fp.children) d1 = list(ose.__dict__.keys()) d1.remove('originalException') d2 = list(ose.originalException.__dict__.keys()) d1.sort() d2.sort() self.assertEqual(d1, d2)
Verify that the Unlistable exception raised will preserve the attributes of the previously-raised exception.
test_keepOriginalAttributes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def read(self, n=0): """ @raise IOError: Always raised. """ raise IOError()
@raise IOError: Always raised.
read
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def write(self, what): """ @raise IOError: Always raised. """ raise IOError()
@raise IOError: Always raised.
write
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def close(self): """ Mark the file as having been closed. """ self.closed = True
Mark the file as having been closed.
close
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def open(self, *a, **k): """ Override 'open' to track all files opened by this path. """ f = filepath.FilePath.open(self, *a, **k) self.openedFiles.append(f) return f
Override 'open' to track all files opened by this path.
open
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def openedPaths(self): """ Return a list of all L{TrackingFilePath}s associated with this L{TrackingFilePath} that have had their C{open()} method called. """ return [path for path in self.trackingList if path.openedFiles]
Return a list of all L{TrackingFilePath}s associated with this L{TrackingFilePath} that have had their C{open()} method called.
openedPaths
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def clonePath(self, name): """ Override L{filepath.FilePath.clonePath} to give the new path a reference to the same tracking list. """ clone = TrackingFilePath(name, trackingList=self.trackingList) self.trackingList.append(clone) return clone
Override L{filepath.FilePath.clonePath} to give the new path a reference to the same tracking list.
clonePath
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def __init__(self, pathName, originalExploder=None): """ Initialize an L{ExplodingFilePath} with a name and a reference to the @param pathName: The path name as passed to L{filepath.FilePath}. @type pathName: C{str} @param originalExploder: The L{ExplodingFilePath} to associate opened files with. @type originalExploder: L{ExplodingFilePath} """ filepath.FilePath.__init__(self, pathName) if originalExploder is None: originalExploder = self self._originalExploder = originalExploder
Initialize an L{ExplodingFilePath} with a name and a reference to the @param pathName: The path name as passed to L{filepath.FilePath}. @type pathName: C{str} @param originalExploder: The L{ExplodingFilePath} to associate opened files with. @type originalExploder: L{ExplodingFilePath}
__init__
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def open(self, mode=None): """ Create, save, and return a new C{ExplodingFile}. @param mode: Present for signature compatibility. Ignored. @return: A new C{ExplodingFile}. """ f = self._originalExploder.fp = ExplodingFile() return f
Create, save, and return a new C{ExplodingFile}. @param mode: Present for signature compatibility. Ignored. @return: A new C{ExplodingFile}.
open
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def assertNotUnequal(self, first, second, msg=None): """ Tests that C{first} != C{second} is false. This method tests the __ne__ method, as opposed to L{assertEqual} (C{first} == C{second}), which tests the __eq__ method. Note: this should really be part of trial """ if first != second: if msg is None: msg = ''; if len(msg) > 0: msg += '\n' raise self.failureException( '%snot not unequal (__ne__ not implemented correctly):' '\na = %s\nb = %s\n' % (msg, pformat(first), pformat(second))) return first
Tests that C{first} != C{second} is false. This method tests the __ne__ method, as opposed to L{assertEqual} (C{first} == C{second}), which tests the __eq__ method. Note: this should really be part of trial
assertNotUnequal
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_rwxFromBools(self): """ L{RWX}'s constructor takes a set of booleans """ for r in (True, False): for w in (True, False): for x in (True, False): rwx = filepath.RWX(r, w, x) self.assertEqual(rwx.read, r) self.assertEqual(rwx.write, w) self.assertEqual(rwx.execute, x) rwx = filepath.RWX(True, True, True) self.assertTrue(rwx.read and rwx.write and rwx.execute)
L{RWX}'s constructor takes a set of booleans
test_rwxFromBools
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_rwxEqNe(self): """ L{RWX}'s created with the same booleans are equivalent. If booleans are different, they are not equal. """ for r in (True, False): for w in (True, False): for x in (True, False): self.assertEqual(filepath.RWX(r, w, x), filepath.RWX(r, w, x)) self.assertNotUnequal(filepath.RWX(r, w, x), filepath.RWX(r, w, x)) self.assertNotEqual(filepath.RWX(True, True, True), filepath.RWX(True, True, False)) self.assertNotEqual(3, filepath.RWX(True, True, True))
L{RWX}'s created with the same booleans are equivalent. If booleans are different, they are not equal.
test_rwxEqNe
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_rwxShorthand(self): """ L{RWX}'s shorthand string should be 'rwx' if read, write, and execute permission bits are true. If any of those permissions bits are false, the character is replaced by a '-'. """ def getChar(val, letter): if val: return letter return '-' for r in (True, False): for w in (True, False): for x in (True, False): rwx = filepath.RWX(r, w, x) self.assertEqual(rwx.shorthand(), getChar(r, 'r') + getChar(w, 'w') + getChar(x, 'x')) self.assertEqual(filepath.RWX(True, False, True).shorthand(), "r-x")
L{RWX}'s shorthand string should be 'rwx' if read, write, and execute permission bits are true. If any of those permissions bits are false, the character is replaced by a '-'.
test_rwxShorthand
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_permissionsFromStat(self): """ L{Permissions}'s constructor takes a valid permissions bitmask and parsaes it to produce the correct set of boolean permissions. """ def _rwxFromStat(statModeInt, who): def getPermissionBit(what, who): return (statModeInt & getattr(stat, "S_I%s%s" % (what, who))) > 0 return filepath.RWX(*[getPermissionBit(what, who) for what in ('R', 'W', 'X')]) for u in range(0, 8): for g in range(0, 8): for o in range(0, 8): chmodString = "%d%d%d" % (u, g, o) chmodVal = int(chmodString, 8) perm = filepath.Permissions(chmodVal) self.assertEqual(perm.user, _rwxFromStat(chmodVal, "USR"), "%s: got user: %s" % (chmodString, perm.user)) self.assertEqual(perm.group, _rwxFromStat(chmodVal, "GRP"), "%s: got group: %s" % (chmodString, perm.group)) self.assertEqual(perm.other, _rwxFromStat(chmodVal, "OTH"), "%s: got other: %s" % (chmodString, perm.other)) perm = filepath.Permissions(0o777) for who in ("user", "group", "other"): for what in ("read", "write", "execute"): self.assertTrue(getattr(getattr(perm, who), what))
L{Permissions}'s constructor takes a valid permissions bitmask and parsaes it to produce the correct set of boolean permissions.
test_permissionsFromStat
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_permissionsEq(self): """ Two L{Permissions}'s that are created with the same bitmask are equivalent """ self.assertEqual(filepath.Permissions(0o777), filepath.Permissions(0o777)) self.assertNotUnequal(filepath.Permissions(0o777), filepath.Permissions(0o777)) self.assertNotEqual(filepath.Permissions(0o777), filepath.Permissions(0o700)) self.assertNotEqual(3, filepath.Permissions(0o777))
Two L{Permissions}'s that are created with the same bitmask are equivalent
test_permissionsEq
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_permissionsShorthand(self): """ L{Permissions}'s shorthand string is the RWX shorthand string for its user permission bits, group permission bits, and other permission bits concatenated together, without a space. """ for u in range(0, 8): for g in range(0, 8): for o in range(0, 8): perm = filepath.Permissions(int("0o%d%d%d" % (u, g, o), 8)) self.assertEqual(perm.shorthand(), ''.join(x.shorthand() for x in ( perm.user, perm.group, perm.other))) self.assertEqual(filepath.Permissions(0o770).shorthand(), "rwxrwx---")
L{Permissions}'s shorthand string is the RWX shorthand string for its user permission bits, group permission bits, and other permission bits concatenated together, without a space.
test_permissionsShorthand
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_chmod(self): """ L{FilePath.chmod} modifies the permissions of the passed file as expected (using C{os.stat} to check). We use some basic modes that should work everywhere (even on Windows). """ for mode in (0o555, 0o777): self.path.child(b"sub1").chmod(mode) self.assertEqual( stat.S_IMODE(os.stat(self.path.child(b"sub1").path).st_mode), mode)
L{FilePath.chmod} modifies the permissions of the passed file as expected (using C{os.stat} to check). We use some basic modes that should work everywhere (even on Windows).
test_chmod
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def symlink(self, target, name): """ Create a symbolic link named C{name} pointing at C{target}. @type target: C{str} @type name: C{str} @raise SkipTest: raised if symbolic links are not supported on the host platform. """ if symlinkSkip: raise SkipTest(symlinkSkip) os.symlink(target, name)
Create a symbolic link named C{name} pointing at C{target}. @type target: C{str} @type name: C{str} @raise SkipTest: raised if symbolic links are not supported on the host platform.
symlink
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def createLinks(self): """ Create several symbolic links to files and directories. """ subdir = self.path.child(b"sub1") self.symlink(subdir.path, self._mkpath(b"sub1.link")) self.symlink(subdir.child(b"file2").path, self._mkpath(b"file2.link")) self.symlink(subdir.child(b"file2").path, self._mkpath(b"sub1", b"sub1.file2.link"))
Create several symbolic links to files and directories.
createLinks
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_realpathSymlink(self): """ L{FilePath.realpath} returns the path of the ultimate target of a symlink. """ self.createLinks() self.symlink(self.path.child(b"file2.link").path, self.path.child(b"link.link").path) self.assertEqual(self.path.child(b"link.link").realpath(), self.path.child(b"sub1").child(b"file2"))
L{FilePath.realpath} returns the path of the ultimate target of a symlink.
test_realpathSymlink
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_realpathCyclicalSymlink(self): """ L{FilePath.realpath} raises L{filepath.LinkError} if the path is a symbolic link which is part of a cycle. """ self.symlink(self.path.child(b"link1").path, self.path.child(b"link2").path) self.symlink(self.path.child(b"link2").path, self.path.child(b"link1").path) self.assertRaises(filepath.LinkError, self.path.child(b"link2").realpath)
L{FilePath.realpath} raises L{filepath.LinkError} if the path is a symbolic link which is part of a cycle.
test_realpathCyclicalSymlink
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_realpathNoSymlink(self): """ L{FilePath.realpath} returns the path itself if the path is not a symbolic link. """ self.assertEqual(self.path.child(b"sub1").realpath(), self.path.child(b"sub1"))
L{FilePath.realpath} returns the path itself if the path is not a symbolic link.
test_realpathNoSymlink
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_walkCyclicalSymlink(self): """ Verify that walking a path with a cyclical symlink raises an error """ self.createLinks() self.symlink(self.path.child(b"sub1").path, self.path.child(b"sub1").child(b"sub1.loopylink").path) def iterateOverPath(): return [foo.path for foo in self.path.walk()] self.assertRaises(filepath.LinkError, iterateOverPath)
Verify that walking a path with a cyclical symlink raises an error
test_walkCyclicalSymlink
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_walkObeysDescendWithCyclicalSymlinks(self): """ Verify that, after making a path with cyclical symlinks, when the supplied C{descend} predicate returns C{False}, the target is not traversed, as if it was a simple symlink. """ self.createLinks() # we create cyclical symlinks self.symlink(self.path.child(b"sub1").path, self.path.child(b"sub1").child(b"sub1.loopylink").path) def noSymLinks(path): return not path.islink() def iterateOverPath(): return [foo.path for foo in self.path.walk(descend=noSymLinks)] self.assertTrue(iterateOverPath())
Verify that, after making a path with cyclical symlinks, when the supplied C{descend} predicate returns C{False}, the target is not traversed, as if it was a simple symlink.
test_walkObeysDescendWithCyclicalSymlinks
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_walkObeysDescend(self): """ Verify that when the supplied C{descend} predicate returns C{False}, the target is not traversed. """ self.createLinks() def noSymLinks(path): return not path.islink() x = [foo.path for foo in self.path.walk(descend=noSymLinks)] self.assertEqual(set(x), set(self.all))
Verify that when the supplied C{descend} predicate returns C{False}, the target is not traversed.
test_walkObeysDescend
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_getContentFileClosing(self): """ If reading from the underlying file raises an exception, L{FilePath.getContent} raises that exception after closing the file. """ fp = ExplodingFilePath(b"") self.assertRaises(IOError, fp.getContent) self.assertTrue(fp.fp.closed)
If reading from the underlying file raises an exception, L{FilePath.getContent} raises that exception after closing the file.
test_getContentFileClosing
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_symbolicLink(self): """ Verify the behavior of the C{isLink} method against links and non-links. Also check that the symbolic link shares the directory property with its target. """ s4 = self.path.child(b"sub4") s3 = self.path.child(b"sub3") self.symlink(s3.path, s4.path) self.assertTrue(s4.islink()) self.assertFalse(s3.islink()) self.assertTrue(s4.isdir()) self.assertTrue(s3.isdir())
Verify the behavior of the C{isLink} method against links and non-links. Also check that the symbolic link shares the directory property with its target.
test_symbolicLink
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_linkTo(self): """ Verify that symlink creates a valid symlink that is both a link and a file if its target is a file, or a directory if its target is a directory. """ targetLinks = [ (self.path.child(b"sub2"), self.path.child(b"sub2.link")), (self.path.child(b"sub2").child(b"file3.ext1"), self.path.child(b"file3.ext1.link")) ] for target, link in targetLinks: target.linkTo(link) self.assertTrue(link.islink(), "This is a link") self.assertEqual(target.isdir(), link.isdir()) self.assertEqual(target.isfile(), link.isfile())
Verify that symlink creates a valid symlink that is both a link and a file if its target is a file, or a directory if its target is a directory.
test_linkTo
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_linkToErrors(self): """ Verify C{linkTo} fails in the following case: - the target is in a directory that doesn't exist - the target already exists """ self.assertRaises(OSError, self.path.child(b"file1").linkTo, self.path.child(b'nosub').child(b'file1')) self.assertRaises(OSError, self.path.child(b"file1").linkTo, self.path.child(b'sub1').child(b'file2'))
Verify C{linkTo} fails in the following case: - the target is in a directory that doesn't exist - the target already exists
test_linkToErrors
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def testInsecureWin32Whacky(self): """ Windows has 'special' filenames like NUL and CON and COM1 and LPR and PRN and ... god knows what else. They can be located anywhere in the filesystem. For obvious reasons, we do not wish to normally permit access to these. """ self.assertRaises(filepath.InsecurePath, self.path.child, b"CON") self.assertRaises(filepath.InsecurePath, self.path.child, b"C:CON") self.assertRaises(filepath.InsecurePath, self.path.child, r"C:\CON")
Windows has 'special' filenames like NUL and CON and COM1 and LPR and PRN and ... god knows what else. They can be located anywhere in the filesystem. For obvious reasons, we do not wish to normally permit access to these.
testInsecureWin32Whacky
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_descendantOnly(self): """ If C{".."} is in the sequence passed to L{FilePath.descendant}, L{InsecurePath} is raised. """ self.assertRaises( filepath.InsecurePath, self.path.descendant, [u'mon\u20acy', u'..'])
If C{".."} is in the sequence passed to L{FilePath.descendant}, L{InsecurePath} is raised.
test_descendantOnly
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_temporarySiblingExtension(self): """ If L{FilePath.temporarySibling} is given an extension argument, it will produce path objects with that extension appended to their names. """ testExtension = b".test-extension" ts = self.path.temporarySibling(testExtension) self.assertTrue(ts.basename().endswith(testExtension), "%s does not end with %s" % ( ts.basename(), testExtension))
If L{FilePath.temporarySibling} is given an extension argument, it will produce path objects with that extension appended to their names.
test_temporarySiblingExtension
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_removeDirectory(self): """ L{FilePath.remove} on a L{FilePath} that refers to a directory will recursively delete its contents. """ self.path.remove() self.assertFalse(self.path.exists())
L{FilePath.remove} on a L{FilePath} that refers to a directory will recursively delete its contents.
test_removeDirectory
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_removeWithSymlink(self): """ For a path which is a symbolic link, L{FilePath.remove} just deletes the link, not the target. """ link = self.path.child(b"sub1.link") # setUp creates the sub1 child self.symlink(self.path.child(b"sub1").path, link.path) link.remove() self.assertFalse(link.exists()) self.assertTrue(self.path.child(b"sub1").exists())
For a path which is a symbolic link, L{FilePath.remove} just deletes the link, not the target.
test_removeWithSymlink
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_copyToDirectory(self): """ L{FilePath.copyTo} makes a copy of all the contents of the directory named by that L{FilePath} if it is able to do so. """ oldPaths = list(self.path.walk()) # Record initial state fp = filepath.FilePath(self.mktemp()) self.path.copyTo(fp) self.path.remove() fp.copyTo(self.path) newPaths = list(self.path.walk()) # Record double-copy state newPaths.sort() oldPaths.sort() self.assertEqual(newPaths, oldPaths)
L{FilePath.copyTo} makes a copy of all the contents of the directory named by that L{FilePath} if it is able to do so.
test_copyToDirectory
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_copyToMissingDestFileClosing(self): """ If an exception is raised while L{FilePath.copyTo} is trying to open source file to read from, the destination file is closed and the exception is raised to the caller of L{FilePath.copyTo}. """ nosuch = self.path.child(b"nothere") # Make it look like something to copy, even though it doesn't exist. # This could happen if the file is deleted between the isfile check and # the file actually being opened. nosuch.isfile = lambda: True # We won't get as far as writing to this file, but it's still useful for # tracking whether we closed it. destination = ExplodingFilePath(self.mktemp()) self.assertRaises(IOError, nosuch.copyTo, destination) self.assertTrue(destination.fp.closed)
If an exception is raised while L{FilePath.copyTo} is trying to open source file to read from, the destination file is closed and the exception is raised to the caller of L{FilePath.copyTo}.
test_copyToMissingDestFileClosing
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_copyToFileClosing(self): """ If an exception is raised while L{FilePath.copyTo} is copying bytes between two regular files, the source and destination files are closed and the exception propagates to the caller of L{FilePath.copyTo}. """ destination = ExplodingFilePath(self.mktemp()) source = ExplodingFilePath(__file__) self.assertRaises(IOError, source.copyTo, destination) self.assertTrue(source.fp.closed) self.assertTrue(destination.fp.closed)
If an exception is raised while L{FilePath.copyTo} is copying bytes between two regular files, the source and destination files are closed and the exception propagates to the caller of L{FilePath.copyTo}.
test_copyToFileClosing
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_copyToDirectoryItself(self): """ L{FilePath.copyTo} fails with an OSError or IOError (depending on platform, as it propagates errors from open() and write()) when attempting to copy a directory to a child of itself. """ self.assertRaises((OSError, IOError), self.path.copyTo, self.path.child(b'file1'))
L{FilePath.copyTo} fails with an OSError or IOError (depending on platform, as it propagates errors from open() and write()) when attempting to copy a directory to a child of itself.
test_copyToDirectoryItself
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_copyToWithSymlink(self): """ Verify that copying with followLinks=True copies symlink targets instead of symlinks """ self.symlink(self.path.child(b"sub1").path, self.path.child(b"link1").path) fp = filepath.FilePath(self.mktemp()) self.path.copyTo(fp) self.assertFalse(fp.child(b"link1").islink()) self.assertEqual([x.basename() for x in fp.child(b"sub1").children()], [x.basename() for x in fp.child(b"link1").children()])
Verify that copying with followLinks=True copies symlink targets instead of symlinks
test_copyToWithSymlink
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_copyToWithoutSymlink(self): """ Verify that copying with followLinks=False copies symlinks as symlinks """ self.symlink(b"sub1", self.path.child(b"link1").path) fp = filepath.FilePath(self.mktemp()) self.path.copyTo(fp, followLinks=False) self.assertTrue(fp.child(b"link1").islink()) self.assertEqual(os.readlink(self.path.child(b"link1").path), os.readlink(fp.child(b"link1").path))
Verify that copying with followLinks=False copies symlinks as symlinks
test_copyToWithoutSymlink
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_copyToMissingSource(self): """ If the source path is missing, L{FilePath.copyTo} raises L{OSError}. """ path = filepath.FilePath(self.mktemp()) exc = self.assertRaises(OSError, path.copyTo, b'some other path') self.assertEqual(exc.errno, errno.ENOENT)
If the source path is missing, L{FilePath.copyTo} raises L{OSError}.
test_copyToMissingSource
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_moveTo(self): """ Verify that moving an entire directory results into another directory with the same content. """ oldPaths = list(self.path.walk()) # Record initial state fp = filepath.FilePath(self.mktemp()) self.path.moveTo(fp) fp.moveTo(self.path) newPaths = list(self.path.walk()) # Record double-move state newPaths.sort() oldPaths.sort() self.assertEqual(newPaths, oldPaths)
Verify that moving an entire directory results into another directory with the same content.
test_moveTo
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT
def test_moveToExistsCache(self): """ A L{FilePath} that has been moved aside with L{FilePath.moveTo} no longer registers as existing. Its previously non-existent target exists, though, as it was created by the call to C{moveTo}. """ fp = filepath.FilePath(self.mktemp()) fp2 = filepath.FilePath(self.mktemp()) fp.touch() # Both a sanity check (make sure the file status looks right) and an # enticement for stat-caching logic to kick in and remember that these # exist / don't exist. self.assertTrue(fp.exists()) self.assertFalse(fp2.exists()) fp.moveTo(fp2) self.assertFalse(fp.exists()) self.assertTrue(fp2.exists())
A L{FilePath} that has been moved aside with L{FilePath.moveTo} no longer registers as existing. Its previously non-existent target exists, though, as it was created by the call to C{moveTo}.
test_moveToExistsCache
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py
MIT