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
182
url
stringlengths
46
251
license
stringclasses
4 values
def test_userinfo(self): """ L{URL.fromText} will parse the C{userinfo} portion of the URI separately from the host and port. """ url = URL.fromText( 'http://someuser:[email protected]/some-segment@ignore' ) self.assertEqual(url.authority(True), 'someuser:[email protected]') self.assertEqual(url.authority(False), 'someuser:@example.com') self.assertEqual(url.userinfo, 'someuser:somepassword') self.assertEqual(url.user, 'someuser') self.assertEqual(url.asText(), 'http://someuser:@example.com/some-segment@ignore') self.assertEqual( url.replace(userinfo=u"someuser").asText(), 'http://[email protected]/some-segment@ignore' )
L{URL.fromText} will parse the C{userinfo} portion of the URI separately from the host and port.
test_userinfo
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_url.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_url.py
MIT
def test_portText(self): """ L{URL.fromText} parses custom port numbers as integers. """ portURL = URL.fromText(u"http://www.example.com:8080/") self.assertEqual(portURL.port, 8080) self.assertEqual(portURL.asText(), u"http://www.example.com:8080/")
L{URL.fromText} parses custom port numbers as integers.
test_portText
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_url.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_url.py
MIT
def test_mailto(self): """ Although L{URL} instances are mainly for dealing with HTTP, other schemes (such as C{mailto:}) should work as well. For example, L{URL.fromText}/L{URL.asText} round-trips cleanly for a C{mailto:} URL representing an email address. """ self.assertEqual(URL.fromText(u"mailto:[email protected]").asText(), u"mailto:[email protected]")
Although L{URL} instances are mainly for dealing with HTTP, other schemes (such as C{mailto:}) should work as well. For example, L{URL.fromText}/L{URL.asText} round-trips cleanly for a C{mailto:} URL representing an email address.
test_mailto
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_url.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_url.py
MIT
def test_queryIterable(self): """ When a L{URL} is created with a C{query} argument, the C{query} argument is converted into an N-tuple of 2-tuples. """ url = URL(query=[[u'alpha', u'beta']]) self.assertEqual(url.query, ((u'alpha', u'beta'),))
When a L{URL} is created with a C{query} argument, the C{query} argument is converted into an N-tuple of 2-tuples.
test_queryIterable
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_url.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_url.py
MIT
def test_technicallyTextIsIterableBut(self): """ Technically, L{str} (or L{unicode}, as appropriate) is iterable, but C{URL(path="foo")} resulting in C{URL.fromText("f/o/o")} is never what you want. """ with self.assertRaises(TypeError) as raised: URL(path=u'foo') self.assertEqual( str(raised.exception), "expected iterable of text for path, not: {}" .format(repr(u'foo')) )
Technically, L{str} (or L{unicode}, as appropriate) is iterable, but C{URL(path="foo")} resulting in C{URL.fromText("f/o/o")} is never what you want.
test_technicallyTextIsIterableBut
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_url.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_url.py
MIT
def test_urlDeprecation(self): """ L{twisted.python.url} is deprecated since Twisted 17.5.0. """ from twisted.python import url url warningsShown = self.flushWarnings([self.test_urlDeprecation]) self.assertEqual(1, len(warningsShown)) self.assertEqual( ("twisted.python.url was deprecated in Twisted 17.5.0:" " Please use hyperlink from PyPI instead."), warningsShown[0]['message'])
L{twisted.python.url} is deprecated since Twisted 17.5.0.
test_urlDeprecation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_url.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_url.py
MIT
def test_inheritedDescriptors(self): """ C{inheritedDescriptors} returns a list of integers giving the file descriptors which were inherited from systemd. """ sddaemon = self.getDaemon(7, 3) self.assertEqual([7, 8, 9], sddaemon.inheritedDescriptors())
C{inheritedDescriptors} returns a list of integers giving the file descriptors which were inherited from systemd.
test_inheritedDescriptors
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
MIT
def test_repeated(self): """ Any subsequent calls to C{inheritedDescriptors} return the same list. """ sddaemon = self.getDaemon(7, 3) self.assertEqual( sddaemon.inheritedDescriptors(), sddaemon.inheritedDescriptors())
Any subsequent calls to C{inheritedDescriptors} return the same list.
test_repeated
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
MIT
def getDaemon(self, start, count): """ Invent C{count} new I{file descriptors} (actually integers, attached to no real file description), starting at C{start}. Construct and return a new L{ListenFDs} which will claim those integers represent inherited file descriptors. """ return ListenFDs(range(start, start + count))
Invent C{count} new I{file descriptors} (actually integers, attached to no real file description), starting at C{start}. Construct and return a new L{ListenFDs} which will claim those integers represent inherited file descriptors.
getDaemon
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
MIT
def initializeEnvironment(self, count, pid): """ Create a copy of the process environment and add I{LISTEN_FDS} and I{LISTEN_PID} (the environment variables set by systemd) to it. """ result = os.environ.copy() result['LISTEN_FDS'] = str(count) result['LISTEN_PID'] = str(pid) return result
Create a copy of the process environment and add I{LISTEN_FDS} and I{LISTEN_PID} (the environment variables set by systemd) to it.
initializeEnvironment
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
MIT
def getDaemon(self, start, count): """ Create a new L{ListenFDs} instance, initialized with a fake environment dictionary which will be set up as systemd would have set it up if C{count} descriptors were being inherited. The descriptors will also start at C{start}. """ fakeEnvironment = self.initializeEnvironment(count, os.getpid()) return ListenFDs.fromEnvironment(environ=fakeEnvironment, start=start)
Create a new L{ListenFDs} instance, initialized with a fake environment dictionary which will be set up as systemd would have set it up if C{count} descriptors were being inherited. The descriptors will also start at C{start}.
getDaemon
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
MIT
def test_secondEnvironment(self): """ Only a single L{Environment} can extract inherited file descriptors. """ fakeEnvironment = self.initializeEnvironment(3, os.getpid()) first = ListenFDs.fromEnvironment(environ=fakeEnvironment) second = ListenFDs.fromEnvironment(environ=fakeEnvironment) self.assertEqual(list(range(3, 6)), first.inheritedDescriptors()) self.assertEqual([], second.inheritedDescriptors())
Only a single L{Environment} can extract inherited file descriptors.
test_secondEnvironment
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
MIT
def test_mismatchedPID(self): """ If the current process PID does not match the PID in the environment, no inherited descriptors are reported. """ fakeEnvironment = self.initializeEnvironment(3, os.getpid() + 1) sddaemon = ListenFDs.fromEnvironment(environ=fakeEnvironment) self.assertEqual([], sddaemon.inheritedDescriptors())
If the current process PID does not match the PID in the environment, no inherited descriptors are reported.
test_mismatchedPID
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
MIT
def test_missingPIDVariable(self): """ If the I{LISTEN_PID} environment variable is not present, no inherited descriptors are reported. """ fakeEnvironment = self.initializeEnvironment(3, os.getpid()) del fakeEnvironment['LISTEN_PID'] sddaemon = ListenFDs.fromEnvironment(environ=fakeEnvironment) self.assertEqual([], sddaemon.inheritedDescriptors())
If the I{LISTEN_PID} environment variable is not present, no inherited descriptors are reported.
test_missingPIDVariable
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
MIT
def test_nonIntegerPIDVariable(self): """ If the I{LISTEN_PID} environment variable is set to a string that cannot be parsed as an integer, no inherited descriptors are reported. """ fakeEnvironment = self.initializeEnvironment(3, "hello, world") sddaemon = ListenFDs.fromEnvironment(environ=fakeEnvironment) self.assertEqual([], sddaemon.inheritedDescriptors())
If the I{LISTEN_PID} environment variable is set to a string that cannot be parsed as an integer, no inherited descriptors are reported.
test_nonIntegerPIDVariable
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
MIT
def test_missingFDSVariable(self): """ If the I{LISTEN_FDS} environment variable is not present, no inherited descriptors are reported. """ fakeEnvironment = self.initializeEnvironment(3, os.getpid()) del fakeEnvironment['LISTEN_FDS'] sddaemon = ListenFDs.fromEnvironment(environ=fakeEnvironment) self.assertEqual([], sddaemon.inheritedDescriptors())
If the I{LISTEN_FDS} environment variable is not present, no inherited descriptors are reported.
test_missingFDSVariable
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
MIT
def test_nonIntegerFDSVariable(self): """ If the I{LISTEN_FDS} environment variable is set to a string that cannot be parsed as an integer, no inherited descriptors are reported. """ fakeEnvironment = self.initializeEnvironment("hello, world", os.getpid()) sddaemon = ListenFDs.fromEnvironment(environ=fakeEnvironment) self.assertEqual([], sddaemon.inheritedDescriptors())
If the I{LISTEN_FDS} environment variable is set to a string that cannot be parsed as an integer, no inherited descriptors are reported.
test_nonIntegerFDSVariable
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
MIT
def test_defaultEnviron(self): """ If the process environment is not explicitly passed to L{Environment.__init__}, the real process environment dictionary is used. """ self.patch(os, 'environ', { 'LISTEN_PID': str(os.getpid()), 'LISTEN_FDS': '5'}) sddaemon = ListenFDs.fromEnvironment() self.assertEqual(list(range(3, 3 + 5)), sddaemon.inheritedDescriptors())
If the process environment is not explicitly passed to L{Environment.__init__}, the real process environment dictionary is used.
test_defaultEnviron
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_systemd.py
MIT
def setUp(self): """ Create a dummy container into which constants can be placed. """ class foo(Names): pass self.container = foo
Create a dummy container into which constants can be placed.
setUp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_name(self): """ The C{name} attribute of a L{NamedConstant} refers to the value passed for the C{name} parameter to C{_realize}. """ name = NamedConstant() name._realize(self.container, "bar", None) self.assertEqual("bar", name.name)
The C{name} attribute of a L{NamedConstant} refers to the value passed for the C{name} parameter to C{_realize}.
test_name
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_representation(self): """ The string representation of an instance of L{NamedConstant} includes the container the instances belongs to as well as the instance's name. """ name = NamedConstant() name._realize(self.container, "bar", None) self.assertEqual("<foo=bar>", repr(name))
The string representation of an instance of L{NamedConstant} includes the container the instances belongs to as well as the instance's name.
test_representation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_equality(self): """ A L{NamedConstant} instance compares equal to itself. """ name = NamedConstant() name._realize(self.container, "bar", None) self.assertTrue(name == name) self.assertFalse(name != name)
A L{NamedConstant} instance compares equal to itself.
test_equality
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_nonequality(self): """ Two different L{NamedConstant} instances do not compare equal to each other. """ first = NamedConstant() first._realize(self.container, "bar", None) second = NamedConstant() second._realize(self.container, "bar", None) self.assertFalse(first == second) self.assertTrue(first != second)
Two different L{NamedConstant} instances do not compare equal to each other.
test_nonequality
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_hash(self): """ Because two different L{NamedConstant} instances do not compare as equal to each other, they also have different hashes to avoid collisions when added to a C{dict} or C{set}. """ first = NamedConstant() first._realize(self.container, "bar", None) second = NamedConstant() second._realize(self.container, "bar", None) self.assertNotEqual(hash(first), hash(second))
Because two different L{NamedConstant} instances do not compare as equal to each other, they also have different hashes to avoid collisions when added to a C{dict} or C{set}.
test_hash
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def _notInstantiableTest(self, name, cls): """ Assert that an attempt to instantiate the constants class raises C{TypeError}. @param name: A C{str} giving the name of the constants collection. @param cls: The constants class to test. """ exc = self.assertRaises(TypeError, cls) self.assertEqual(name + " may not be instantiated.", str(exc))
Assert that an attempt to instantiate the constants class raises C{TypeError}. @param name: A C{str} giving the name of the constants collection. @param cls: The constants class to test.
_notInstantiableTest
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def _initializedOnceTest(self, container, constantName): """ Assert that C{container._enumerants} does not change as a side-effect of one of its attributes being accessed. @param container: A L{_ConstantsContainer} subclass which will be tested. @param constantName: The name of one of the constants which is an attribute of C{container}. """ first = container._enumerants # Accessing an attribute of the container should not have any # observable side-effect on the _enumerants attribute. getattr(container, constantName) second = container._enumerants self.assertIs(first, second)
Assert that C{container._enumerants} does not change as a side-effect of one of its attributes being accessed. @param container: A L{_ConstantsContainer} subclass which will be tested. @param constantName: The name of one of the constants which is an attribute of C{container}.
_initializedOnceTest
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def setUp(self): """ Create a fresh new L{Names} subclass for each unit test to use. Since L{Names} is stateful, re-using the same subclass across test methods makes exercising all of the implementation code paths difficult. """ class METHOD(Names): """ A container for some named constants to use in unit tests for L{Names}. """ GET = NamedConstant() PUT = NamedConstant() POST = NamedConstant() DELETE = NamedConstant() extra = object() self.METHOD = METHOD
Create a fresh new L{Names} subclass for each unit test to use. Since L{Names} is stateful, re-using the same subclass across test methods makes exercising all of the implementation code paths difficult.
setUp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_notInstantiable(self): """ A subclass of L{Names} raises C{TypeError} if an attempt is made to instantiate it. """ self._notInstantiableTest("METHOD", self.METHOD)
A subclass of L{Names} raises C{TypeError} if an attempt is made to instantiate it.
test_notInstantiable
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_symbolicAttributes(self): """ Each name associated with a L{NamedConstant} instance in the definition of a L{Names} subclass is available as an attribute on the resulting class. """ self.assertTrue(hasattr(self.METHOD, "GET")) self.assertTrue(hasattr(self.METHOD, "PUT")) self.assertTrue(hasattr(self.METHOD, "POST")) self.assertTrue(hasattr(self.METHOD, "DELETE"))
Each name associated with a L{NamedConstant} instance in the definition of a L{Names} subclass is available as an attribute on the resulting class.
test_symbolicAttributes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_withoutOtherAttributes(self): """ As usual, names not defined in the class scope of a L{Names} subclass are not available as attributes on the resulting class. """ self.assertFalse(hasattr(self.METHOD, "foo"))
As usual, names not defined in the class scope of a L{Names} subclass are not available as attributes on the resulting class.
test_withoutOtherAttributes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_representation(self): """ The string representation of a constant on a L{Names} subclass includes the name of the L{Names} subclass and the name of the constant itself. """ self.assertEqual("<METHOD=GET>", repr(self.METHOD.GET))
The string representation of a constant on a L{Names} subclass includes the name of the L{Names} subclass and the name of the constant itself.
test_representation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_lookupByName(self): """ Constants can be looked up by name using L{Names.lookupByName}. """ method = self.METHOD.lookupByName("GET") self.assertIs(self.METHOD.GET, method)
Constants can be looked up by name using L{Names.lookupByName}.
test_lookupByName
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_notLookupMissingByName(self): """ Names not defined with a L{NamedConstant} instance cannot be looked up using L{Names.lookupByName}. """ self.assertRaises(ValueError, self.METHOD.lookupByName, "lookupByName") self.assertRaises(ValueError, self.METHOD.lookupByName, "__init__") self.assertRaises(ValueError, self.METHOD.lookupByName, "foo") self.assertRaises(ValueError, self.METHOD.lookupByName, "extra")
Names not defined with a L{NamedConstant} instance cannot be looked up using L{Names.lookupByName}.
test_notLookupMissingByName
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_name(self): """ The C{name} attribute of one of the named constants gives that constant's name. """ self.assertEqual("GET", self.METHOD.GET.name)
The C{name} attribute of one of the named constants gives that constant's name.
test_name
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_attributeIdentity(self): """ Repeated access of an attribute associated with a L{NamedConstant} value in a L{Names} subclass results in the same object. """ self.assertIs(self.METHOD.GET, self.METHOD.GET)
Repeated access of an attribute associated with a L{NamedConstant} value in a L{Names} subclass results in the same object.
test_attributeIdentity
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_iterconstants(self): """ L{Names.iterconstants} returns an iterator over all of the constants defined in the class, in the order they were defined. """ constants = list(self.METHOD.iterconstants()) self.assertEqual( [self.METHOD.GET, self.METHOD.PUT, self.METHOD.POST, self.METHOD.DELETE], constants)
L{Names.iterconstants} returns an iterator over all of the constants defined in the class, in the order they were defined.
test_iterconstants
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_attributeIterconstantsIdentity(self): """ The constants returned from L{Names.iterconstants} are identical to the constants accessible using attributes. """ constants = list(self.METHOD.iterconstants()) self.assertIs(self.METHOD.GET, constants[0]) self.assertIs(self.METHOD.PUT, constants[1]) self.assertIs(self.METHOD.POST, constants[2]) self.assertIs(self.METHOD.DELETE, constants[3])
The constants returned from L{Names.iterconstants} are identical to the constants accessible using attributes.
test_attributeIterconstantsIdentity
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_iterconstantsIdentity(self): """ The constants returned from L{Names.iterconstants} are identical on each call to that method. """ constants = list(self.METHOD.iterconstants()) again = list(self.METHOD.iterconstants()) self.assertIs(again[0], constants[0]) self.assertIs(again[1], constants[1]) self.assertIs(again[2], constants[2]) self.assertIs(again[3], constants[3])
The constants returned from L{Names.iterconstants} are identical on each call to that method.
test_iterconstantsIdentity
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_initializedOnce(self): """ L{Names._enumerants} is initialized once and its value re-used on subsequent access. """ self._initializedOnceTest(self.METHOD, "GET")
L{Names._enumerants} is initialized once and its value re-used on subsequent access.
test_initializedOnce
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_asForeignClassAttribute(self): """ A constant defined on a L{Names} subclass may be set as an attribute of another class and then retrieved using that attribute. """ class Another(object): something = self.METHOD.GET self.assertIs(self.METHOD.GET, Another.something)
A constant defined on a L{Names} subclass may be set as an attribute of another class and then retrieved using that attribute.
test_asForeignClassAttribute
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_asForeignClassAttributeViaInstance(self): """ A constant defined on a L{Names} subclass may be set as an attribute of another class and then retrieved from an instance of that class using that attribute. """ class Another(object): something = self.METHOD.GET self.assertIs(self.METHOD.GET, Another().something)
A constant defined on a L{Names} subclass may be set as an attribute of another class and then retrieved from an instance of that class using that attribute.
test_asForeignClassAttributeViaInstance
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_notAsAlternateContainerAttribute(self): """ It is explicitly disallowed (via a L{ValueError}) to use a constant defined on a L{Names} subclass as the value of an attribute of another L{Names} subclass. """ def defineIt(): class AnotherNames(Names): something = self.METHOD.GET exc = self.assertRaises(ValueError, defineIt) self.assertEqual( "Cannot use <METHOD=GET> as the value of an attribute on " "AnotherNames", str(exc))
It is explicitly disallowed (via a L{ValueError}) to use a constant defined on a L{Names} subclass as the value of an attribute of another L{Names} subclass.
test_notAsAlternateContainerAttribute
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def setUp(self): """ Create a fresh new L{Values} subclass for each unit test to use. Since L{Values} is stateful, re-using the same subclass across test methods makes exercising all of the implementation code paths difficult. """ class STATUS(Values): OK = ValueConstant("200") NOT_FOUND = ValueConstant("404") self.STATUS = STATUS
Create a fresh new L{Values} subclass for each unit test to use. Since L{Values} is stateful, re-using the same subclass across test methods makes exercising all of the implementation code paths difficult.
setUp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_notInstantiable(self): """ A subclass of L{Values} raises C{TypeError} if an attempt is made to instantiate it. """ self._notInstantiableTest("STATUS", self.STATUS)
A subclass of L{Values} raises C{TypeError} if an attempt is made to instantiate it.
test_notInstantiable
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_symbolicAttributes(self): """ Each name associated with a L{ValueConstant} instance in the definition of a L{Values} subclass is available as an attribute on the resulting class. """ self.assertTrue(hasattr(self.STATUS, "OK")) self.assertTrue(hasattr(self.STATUS, "NOT_FOUND"))
Each name associated with a L{ValueConstant} instance in the definition of a L{Values} subclass is available as an attribute on the resulting class.
test_symbolicAttributes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_withoutOtherAttributes(self): """ As usual, names not defined in the class scope of a L{Values} subclass are not available as attributes on the resulting class. """ self.assertFalse(hasattr(self.STATUS, "foo"))
As usual, names not defined in the class scope of a L{Values} subclass are not available as attributes on the resulting class.
test_withoutOtherAttributes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_representation(self): """ The string representation of a constant on a L{Values} subclass includes the name of the L{Values} subclass and the name of the constant itself. """ self.assertEqual("<STATUS=OK>", repr(self.STATUS.OK))
The string representation of a constant on a L{Values} subclass includes the name of the L{Values} subclass and the name of the constant itself.
test_representation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_lookupByName(self): """ Constants can be looked up by name using L{Values.lookupByName}. """ method = self.STATUS.lookupByName("OK") self.assertIs(self.STATUS.OK, method)
Constants can be looked up by name using L{Values.lookupByName}.
test_lookupByName
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_notLookupMissingByName(self): """ Names not defined with a L{ValueConstant} instance cannot be looked up using L{Values.lookupByName}. """ self.assertRaises(ValueError, self.STATUS.lookupByName, "lookupByName") self.assertRaises(ValueError, self.STATUS.lookupByName, "__init__") self.assertRaises(ValueError, self.STATUS.lookupByName, "foo")
Names not defined with a L{ValueConstant} instance cannot be looked up using L{Values.lookupByName}.
test_notLookupMissingByName
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_lookupByValue(self): """ Constants can be looked up by their associated value, defined by the argument passed to L{ValueConstant}, using L{Values.lookupByValue}. """ status = self.STATUS.lookupByValue("200") self.assertIs(self.STATUS.OK, status)
Constants can be looked up by their associated value, defined by the argument passed to L{ValueConstant}, using L{Values.lookupByValue}.
test_lookupByValue
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_lookupDuplicateByValue(self): """ If more than one constant is associated with a particular value, L{Values.lookupByValue} returns whichever of them is defined first. """ class TRANSPORT_MESSAGE(Values): """ Message types supported by an SSH transport. """ KEX_DH_GEX_REQUEST_OLD = ValueConstant(30) KEXDH_INIT = ValueConstant(30) self.assertIs( TRANSPORT_MESSAGE.lookupByValue(30), TRANSPORT_MESSAGE.KEX_DH_GEX_REQUEST_OLD)
If more than one constant is associated with a particular value, L{Values.lookupByValue} returns whichever of them is defined first.
test_lookupDuplicateByValue
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_notLookupMissingByValue(self): """ L{Values.lookupByValue} raises L{ValueError} when called with a value with which no constant is associated. """ self.assertRaises(ValueError, self.STATUS.lookupByValue, "OK") self.assertRaises(ValueError, self.STATUS.lookupByValue, 200) self.assertRaises(ValueError, self.STATUS.lookupByValue, "200.1")
L{Values.lookupByValue} raises L{ValueError} when called with a value with which no constant is associated.
test_notLookupMissingByValue
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_name(self): """ The C{name} attribute of one of the constants gives that constant's name. """ self.assertEqual("OK", self.STATUS.OK.name)
The C{name} attribute of one of the constants gives that constant's name.
test_name
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_attributeIdentity(self): """ Repeated access of an attribute associated with a L{ValueConstant} value in a L{Values} subclass results in the same object. """ self.assertIs(self.STATUS.OK, self.STATUS.OK)
Repeated access of an attribute associated with a L{ValueConstant} value in a L{Values} subclass results in the same object.
test_attributeIdentity
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_iterconstants(self): """ L{Values.iterconstants} returns an iterator over all of the constants defined in the class, in the order they were defined. """ constants = list(self.STATUS.iterconstants()) self.assertEqual( [self.STATUS.OK, self.STATUS.NOT_FOUND], constants)
L{Values.iterconstants} returns an iterator over all of the constants defined in the class, in the order they were defined.
test_iterconstants
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_attributeIterconstantsIdentity(self): """ The constants returned from L{Values.iterconstants} are identical to the constants accessible using attributes. """ constants = list(self.STATUS.iterconstants()) self.assertIs(self.STATUS.OK, constants[0]) self.assertIs(self.STATUS.NOT_FOUND, constants[1])
The constants returned from L{Values.iterconstants} are identical to the constants accessible using attributes.
test_attributeIterconstantsIdentity
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_iterconstantsIdentity(self): """ The constants returned from L{Values.iterconstants} are identical on each call to that method. """ constants = list(self.STATUS.iterconstants()) again = list(self.STATUS.iterconstants()) self.assertIs(again[0], constants[0]) self.assertIs(again[1], constants[1])
The constants returned from L{Values.iterconstants} are identical on each call to that method.
test_iterconstantsIdentity
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_initializedOnce(self): """ L{Values._enumerants} is initialized once and its value re-used on subsequent access. """ self._initializedOnceTest(self.STATUS, "OK")
L{Values._enumerants} is initialized once and its value re-used on subsequent access.
test_initializedOnce
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def setUp(self): """ Create a fresh new L{Flags} subclass for each unit test to use. Since L{Flags} is stateful, re-using the same subclass across test methods makes exercising all of the implementation code paths difficult. """ class FXF(Flags): # Implicitly assign three flag values based on definition order READ = FlagConstant() WRITE = FlagConstant() APPEND = FlagConstant() # Explicitly assign one flag value by passing it in EXCLUSIVE = FlagConstant(0x20) # Implicitly assign another flag value, following the previously # specified explicit value. TEXT = FlagConstant() self.FXF = FXF
Create a fresh new L{Flags} subclass for each unit test to use. Since L{Flags} is stateful, re-using the same subclass across test methods makes exercising all of the implementation code paths difficult.
setUp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_notInstantiable(self): """ A subclass of L{Flags} raises L{TypeError} if an attempt is made to instantiate it. """ self._notInstantiableTest("FXF", self.FXF)
A subclass of L{Flags} raises L{TypeError} if an attempt is made to instantiate it.
test_notInstantiable
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_symbolicAttributes(self): """ Each name associated with a L{FlagConstant} instance in the definition of a L{Flags} subclass is available as an attribute on the resulting class. """ self.assertTrue(hasattr(self.FXF, "READ")) self.assertTrue(hasattr(self.FXF, "WRITE")) self.assertTrue(hasattr(self.FXF, "APPEND")) self.assertTrue(hasattr(self.FXF, "EXCLUSIVE")) self.assertTrue(hasattr(self.FXF, "TEXT"))
Each name associated with a L{FlagConstant} instance in the definition of a L{Flags} subclass is available as an attribute on the resulting class.
test_symbolicAttributes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_withoutOtherAttributes(self): """ As usual, names not defined in the class scope of a L{Flags} subclass are not available as attributes on the resulting class. """ self.assertFalse(hasattr(self.FXF, "foo"))
As usual, names not defined in the class scope of a L{Flags} subclass are not available as attributes on the resulting class.
test_withoutOtherAttributes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_representation(self): """ The string representation of a constant on a L{Flags} subclass includes the name of the L{Flags} subclass and the name of the constant itself. """ self.assertEqual("<FXF=READ>", repr(self.FXF.READ))
The string representation of a constant on a L{Flags} subclass includes the name of the L{Flags} subclass and the name of the constant itself.
test_representation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_lookupByName(self): """ Constants can be looked up by name using L{Flags.lookupByName}. """ flag = self.FXF.lookupByName("READ") self.assertIs(self.FXF.READ, flag)
Constants can be looked up by name using L{Flags.lookupByName}.
test_lookupByName
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_notLookupMissingByName(self): """ Names not defined with a L{FlagConstant} instance cannot be looked up using L{Flags.lookupByName}. """ self.assertRaises(ValueError, self.FXF.lookupByName, "lookupByName") self.assertRaises(ValueError, self.FXF.lookupByName, "__init__") self.assertRaises(ValueError, self.FXF.lookupByName, "foo")
Names not defined with a L{FlagConstant} instance cannot be looked up using L{Flags.lookupByName}.
test_notLookupMissingByName
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_lookupByValue(self): """ Constants can be looked up by their associated value, defined implicitly by the position in which the constant appears in the class definition or explicitly by the argument passed to L{FlagConstant}. """ flag = self.FXF.lookupByValue(0x01) self.assertIs(flag, self.FXF.READ) flag = self.FXF.lookupByValue(0x02) self.assertIs(flag, self.FXF.WRITE) flag = self.FXF.lookupByValue(0x04) self.assertIs(flag, self.FXF.APPEND) flag = self.FXF.lookupByValue(0x20) self.assertIs(flag, self.FXF.EXCLUSIVE) flag = self.FXF.lookupByValue(0x40) self.assertIs(flag, self.FXF.TEXT)
Constants can be looked up by their associated value, defined implicitly by the position in which the constant appears in the class definition or explicitly by the argument passed to L{FlagConstant}.
test_lookupByValue
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_lookupDuplicateByValue(self): """ If more than one constant is associated with a particular value, L{Flags.lookupByValue} returns whichever of them is defined first. """ class TIMEX(Flags): # (timex.mode) ADJ_OFFSET = FlagConstant(0x0001) # time offset # xntp 3.4 compatibility names MOD_OFFSET = FlagConstant(0x0001) self.assertIs(TIMEX.lookupByValue(0x0001), TIMEX.ADJ_OFFSET)
If more than one constant is associated with a particular value, L{Flags.lookupByValue} returns whichever of them is defined first.
test_lookupDuplicateByValue
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_notLookupMissingByValue(self): """ L{Flags.lookupByValue} raises L{ValueError} when called with a value with which no constant is associated. """ self.assertRaises(ValueError, self.FXF.lookupByValue, 0x10)
L{Flags.lookupByValue} raises L{ValueError} when called with a value with which no constant is associated.
test_notLookupMissingByValue
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_attributeIdentity(self): """ Repeated access of an attribute associated with a L{FlagConstant} value in a L{Flags} subclass results in the same object. """ self.assertIs(self.FXF.READ, self.FXF.READ)
Repeated access of an attribute associated with a L{FlagConstant} value in a L{Flags} subclass results in the same object.
test_attributeIdentity
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_iterconstants(self): """ L{Flags.iterconstants} returns an iterator over all of the constants defined in the class, in the order they were defined. """ constants = list(self.FXF.iterconstants()) self.assertEqual( [self.FXF.READ, self.FXF.WRITE, self.FXF.APPEND, self.FXF.EXCLUSIVE, self.FXF.TEXT], constants)
L{Flags.iterconstants} returns an iterator over all of the constants defined in the class, in the order they were defined.
test_iterconstants
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_attributeIterconstantsIdentity(self): """ The constants returned from L{Flags.iterconstants} are identical to the constants accessible using attributes. """ constants = list(self.FXF.iterconstants()) self.assertIs(self.FXF.READ, constants[0]) self.assertIs(self.FXF.WRITE, constants[1]) self.assertIs(self.FXF.APPEND, constants[2]) self.assertIs(self.FXF.EXCLUSIVE, constants[3]) self.assertIs(self.FXF.TEXT, constants[4])
The constants returned from L{Flags.iterconstants} are identical to the constants accessible using attributes.
test_attributeIterconstantsIdentity
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_iterconstantsIdentity(self): """ The constants returned from L{Flags.iterconstants} are identical on each call to that method. """ constants = list(self.FXF.iterconstants()) again = list(self.FXF.iterconstants()) self.assertIs(again[0], constants[0]) self.assertIs(again[1], constants[1]) self.assertIs(again[2], constants[2]) self.assertIs(again[3], constants[3]) self.assertIs(again[4], constants[4])
The constants returned from L{Flags.iterconstants} are identical on each call to that method.
test_iterconstantsIdentity
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_initializedOnce(self): """ L{Flags._enumerants} is initialized once and its value re-used on subsequent access. """ self._initializedOnceTest(self.FXF, "READ")
L{Flags._enumerants} is initialized once and its value re-used on subsequent access.
test_initializedOnce
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_value(self): """ The value of the L{FlagConstant} which results from C{|} has all of the bits set which were set in either of the values of the two original constants. """ flag = self.FXF.READ | self.FXF.WRITE self.assertEqual( self.FXF.READ.value | self.FXF.WRITE.value, flag.value )
The value of the L{FlagConstant} which results from C{|} has all of the bits set which were set in either of the values of the two original constants.
test_value
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_name(self): """ The name of the L{FlagConstant} instance which results from C{|} includes the names of both of the two original constants. """ flag = self.FXF.READ | self.FXF.WRITE self.assertEqual("{READ,WRITE}", flag.name)
The name of the L{FlagConstant} instance which results from C{|} includes the names of both of the two original constants.
test_name
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_representation(self): """ The string representation of a L{FlagConstant} instance which results from C{|} includes the names of both of the two original constants. """ flag = self.FXF.READ | self.FXF.WRITE self.assertEqual("<FXF={READ,WRITE}>", repr(flag))
The string representation of a L{FlagConstant} instance which results from C{|} includes the names of both of the two original constants.
test_representation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_iterate(self): """ A L{FlagConstant} instance which results from C{|} can be iterated upon to yield the original constants. """ self.assertEqual( set(self.FXF.WRITE & self.FXF.READ), # No flags set(())) self.assertEqual( set(self.FXF.WRITE), set((self.FXF.WRITE,))) self.assertEqual( set(self.FXF.WRITE | self.FXF.EXCLUSIVE), set((self.FXF.WRITE, self.FXF.EXCLUSIVE)))
A L{FlagConstant} instance which results from C{|} can be iterated upon to yield the original constants.
test_iterate
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_membership(self): """ A L{FlagConstant} instance which results from C{|} can be tested for membership. """ flags = self.FXF.WRITE | self.FXF.EXCLUSIVE self.assertIn(self.FXF.WRITE, flags) self.assertNotIn(self.FXF.READ, flags)
A L{FlagConstant} instance which results from C{|} can be tested for membership.
test_membership
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_truthiness(self): """ Empty flags is false, non-empty flags is true. """ self.assertTrue(self.FXF.WRITE) self.assertTrue(self.FXF.WRITE | self.FXF.EXCLUSIVE) self.assertFalse(self.FXF.WRITE & self.FXF.EXCLUSIVE)
Empty flags is false, non-empty flags is true.
test_truthiness
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_value(self): """ The value of the L{FlagConstant} which results from C{&} has all of the bits set which were set in both of the values of the two original constants. """ readWrite = (self.FXF.READ | self.FXF.WRITE) writeAppend = (self.FXF.WRITE | self.FXF.APPEND) flag = readWrite & writeAppend self.assertEqual(self.FXF.WRITE.value, flag.value)
The value of the L{FlagConstant} which results from C{&} has all of the bits set which were set in both of the values of the two original constants.
test_value
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_name(self): """ The name of the L{FlagConstant} instance which results from C{&} includes the names of only the flags which were set in both of the two original constants. """ readWrite = (self.FXF.READ | self.FXF.WRITE) writeAppend = (self.FXF.WRITE | self.FXF.APPEND) flag = readWrite & writeAppend self.assertEqual("WRITE", flag.name)
The name of the L{FlagConstant} instance which results from C{&} includes the names of only the flags which were set in both of the two original constants.
test_name
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_representation(self): """ The string representation of a L{FlagConstant} instance which results from C{&} includes the names of only the flags which were set in both both of the two original constants. """ readWrite = (self.FXF.READ | self.FXF.WRITE) writeAppend = (self.FXF.WRITE | self.FXF.APPEND) flag = readWrite & writeAppend self.assertEqual("<FXF=WRITE>", repr(flag))
The string representation of a L{FlagConstant} instance which results from C{&} includes the names of only the flags which were set in both both of the two original constants.
test_representation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_value(self): """ The value of the L{FlagConstant} which results from C{^} has all of the bits set which were set in exactly one of the values of the two original constants. """ readWrite = (self.FXF.READ | self.FXF.WRITE) writeAppend = (self.FXF.WRITE | self.FXF.APPEND) flag = readWrite ^ writeAppend self.assertEqual( self.FXF.READ.value | self.FXF.APPEND.value, flag.value )
The value of the L{FlagConstant} which results from C{^} has all of the bits set which were set in exactly one of the values of the two original constants.
test_value
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_name(self): """ The name of the L{FlagConstant} instance which results from C{^} includes the names of only the flags which were set in exactly one of the two original constants. """ readWrite = (self.FXF.READ | self.FXF.WRITE) writeAppend = (self.FXF.WRITE | self.FXF.APPEND) flag = readWrite ^ writeAppend self.assertEqual("{APPEND,READ}", flag.name)
The name of the L{FlagConstant} instance which results from C{^} includes the names of only the flags which were set in exactly one of the two original constants.
test_name
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_representation(self): """ The string representation of a L{FlagConstant} instance which results from C{^} includes the names of only the flags which were set in exactly one of the two original constants. """ readWrite = (self.FXF.READ | self.FXF.WRITE) writeAppend = (self.FXF.WRITE | self.FXF.APPEND) flag = readWrite ^ writeAppend self.assertEqual("<FXF={APPEND,READ}>", repr(flag))
The string representation of a L{FlagConstant} instance which results from C{^} includes the names of only the flags which were set in exactly one of the two original constants.
test_representation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_value(self): """ The value of the L{FlagConstant} which results from C{~} has all of the bits set which were not set in the original constant. """ flag = ~self.FXF.READ self.assertEqual( self.FXF.WRITE.value | self.FXF.APPEND.value | self.FXF.EXCLUSIVE.value | self.FXF.TEXT.value, flag.value) flag = ~self.FXF.WRITE self.assertEqual( self.FXF.READ.value | self.FXF.APPEND.value | self.FXF.EXCLUSIVE.value | self.FXF.TEXT.value, flag.value)
The value of the L{FlagConstant} which results from C{~} has all of the bits set which were not set in the original constant.
test_value
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_name(self): """ The name of the L{FlagConstant} instance which results from C{~} includes the names of all the flags which were not set in the original constant. """ flag = ~self.FXF.WRITE self.assertEqual("{APPEND,EXCLUSIVE,READ,TEXT}", flag.name)
The name of the L{FlagConstant} instance which results from C{~} includes the names of all the flags which were not set in the original constant.
test_name
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_representation(self): """ The string representation of a L{FlagConstant} instance which results from C{~} includes the names of all the flags which were not set in the original constant. """ flag = ~self.FXF.WRITE self.assertEqual("<FXF={APPEND,EXCLUSIVE,READ,TEXT}>", repr(flag))
The string representation of a L{FlagConstant} instance which results from C{~} includes the names of all the flags which were not set in the original constant.
test_representation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_orderedNameConstants_lt(self): """ L{twisted.python.constants.NamedConstant} preserves definition order in C{<} comparisons. """ self.assertTrue(NamedLetters.alpha < NamedLetters.beta)
L{twisted.python.constants.NamedConstant} preserves definition order in C{<} comparisons.
test_orderedNameConstants_lt
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_orderedNameConstants_le(self): """ L{twisted.python.constants.NamedConstant} preserves definition order in C{<=} comparisons. """ self.assertTrue(NamedLetters.alpha <= NamedLetters.alpha) self.assertTrue(NamedLetters.alpha <= NamedLetters.beta)
L{twisted.python.constants.NamedConstant} preserves definition order in C{<=} comparisons.
test_orderedNameConstants_le
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_orderedNameConstants_gt(self): """ L{twisted.python.constants.NamedConstant} preserves definition order in C{>} comparisons. """ self.assertTrue(NamedLetters.beta > NamedLetters.alpha)
L{twisted.python.constants.NamedConstant} preserves definition order in C{>} comparisons.
test_orderedNameConstants_gt
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_orderedNameConstants_ge(self): """ L{twisted.python.constants.NamedConstant} preserves definition order in C{>=} comparisons. """ self.assertTrue(NamedLetters.alpha >= NamedLetters.alpha) self.assertTrue(NamedLetters.beta >= NamedLetters.alpha)
L{twisted.python.constants.NamedConstant} preserves definition order in C{>=} comparisons.
test_orderedNameConstants_ge
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_orderedValueConstants_lt(self): """ L{twisted.python.constants.ValueConstant} preserves definition order in C{<} comparisons. """ self.assertTrue(ValuedLetters.alpha < ValuedLetters.digamma) self.assertTrue(ValuedLetters.digamma < ValuedLetters.zeta)
L{twisted.python.constants.ValueConstant} preserves definition order in C{<} comparisons.
test_orderedValueConstants_lt
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_orderedValueConstants_le(self): """ L{twisted.python.constants.ValueConstant} preserves definition order in C{<=} comparisons. """ self.assertTrue(ValuedLetters.alpha <= ValuedLetters.alpha) self.assertTrue(ValuedLetters.alpha <= ValuedLetters.digamma) self.assertTrue(ValuedLetters.digamma <= ValuedLetters.zeta)
L{twisted.python.constants.ValueConstant} preserves definition order in C{<=} comparisons.
test_orderedValueConstants_le
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_orderedValueConstants_gt(self): """ L{twisted.python.constants.ValueConstant} preserves definition order in C{>} comparisons. """ self.assertTrue(ValuedLetters.digamma > ValuedLetters.alpha) self.assertTrue(ValuedLetters.zeta > ValuedLetters.digamma)
L{twisted.python.constants.ValueConstant} preserves definition order in C{>} comparisons.
test_orderedValueConstants_gt
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_orderedValueConstants_ge(self): """ L{twisted.python.constants.ValueConstant} preserves definition order in C{>=} comparisons. """ self.assertTrue(ValuedLetters.alpha >= ValuedLetters.alpha) self.assertTrue(ValuedLetters.digamma >= ValuedLetters.alpha) self.assertTrue(ValuedLetters.zeta >= ValuedLetters.digamma)
L{twisted.python.constants.ValueConstant} preserves definition order in C{>=} comparisons.
test_orderedValueConstants_ge
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_orderedFlagConstants_lt(self): """ L{twisted.python.constants.FlagConstant} preserves definition order in C{<} comparisons. """ self.assertTrue(PizzaToppings.mozzarella < PizzaToppings.pesto) self.assertTrue(PizzaToppings.pesto < PizzaToppings.pepperoni)
L{twisted.python.constants.FlagConstant} preserves definition order in C{<} comparisons.
test_orderedFlagConstants_lt
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_orderedFlagConstants_le(self): """ L{twisted.python.constants.FlagConstant} preserves definition order in C{<=} comparisons. """ self.assertTrue(PizzaToppings.mozzarella <= PizzaToppings.mozzarella) self.assertTrue(PizzaToppings.mozzarella <= PizzaToppings.pesto) self.assertTrue(PizzaToppings.pesto <= PizzaToppings.pepperoni)
L{twisted.python.constants.FlagConstant} preserves definition order in C{<=} comparisons.
test_orderedFlagConstants_le
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_orderedFlagConstants_gt(self): """ L{twisted.python.constants.FlagConstant} preserves definition order in C{>} comparisons. """ self.assertTrue(PizzaToppings.pesto > PizzaToppings.mozzarella) self.assertTrue(PizzaToppings.pepperoni > PizzaToppings.pesto)
L{twisted.python.constants.FlagConstant} preserves definition order in C{>} comparisons.
test_orderedFlagConstants_gt
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT
def test_orderedFlagConstants_ge(self): """ L{twisted.python.constants.FlagConstant} preserves definition order in C{>=} comparisons. """ self.assertTrue(PizzaToppings.mozzarella >= PizzaToppings.mozzarella) self.assertTrue(PizzaToppings.pesto >= PizzaToppings.mozzarella) self.assertTrue(PizzaToppings.pepperoni >= PizzaToppings.pesto)
L{twisted.python.constants.FlagConstant} preserves definition order in C{>=} comparisons.
test_orderedFlagConstants_ge
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_constants.py
MIT