本文整理汇总了Python中test.test_support.requires函数的典型用法代码示例。如果您正苦于以下问题:Python requires函数的具体用法?Python requires怎么用?Python requires使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了requires函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.assertTrue(self.python)
self.assertTrue(self.module)
self.assertTrue(self.error)
test_support.requires("xpickle")
if not have_python_version(self.python):
self.skipTest("%s not available" % self.python)
开发者ID:rahulnij,项目名称:practice-python,代码行数:7,代码来源:test_xpickle.py
示例2: test_timeout
def test_timeout():
test_support.requires('network')
if test_support.verbose:
print "test_timeout ..."
# A service which issues a welcome banner (without need to write
# anything).
# XXX ("gmail.org", 995) has been unreliable so far, from time to time
# XXX non-responsive for hours on end (& across all buildbot slaves,
# XXX so that's not just a local thing).
ADDR = "gmail.org", 995
s = socket.socket()
s.settimeout(30.0)
try:
s.connect(ADDR)
except socket.timeout:
print >> sys.stderr, """\
WARNING: an attempt to connect to %r timed out, in
test_timeout. That may be legitimate, but is not the outcome we hoped
for. If this message is seen often, test_timeout should be changed to
use a more reliable address.""" % (ADDR,)
return
ss = socket.ssl(s)
# Read part of return welcome banner twice.
ss.read(1)
ss.read(1)
s.close()
开发者ID:facchinm,项目名称:SiRFLive,代码行数:30,代码来源:test_socket_ssl.py
示例3: test_timeout
def test_timeout():
test_support.requires('network')
def error_msg(extra_msg):
print >> sys.stderr, """\
WARNING: an attempt to connect to %r %s, in
test_timeout. That may be legitimate, but is not the outcome we hoped
for. If this message is seen often, test_timeout should be changed to
use a more reliable address.""" % (ADDR, extra_msg)
if test_support.verbose:
print "test_timeout ..."
# A service which issues a welcome banner (without need to write
# anything).
ADDR = "pop.gmail.com", 995
s = socket.socket()
s.settimeout(30.0)
try:
s.connect(ADDR)
except socket.timeout:
error_msg('timed out')
return
except socket.error, exc: # In case connection is refused.
if exc.args[0] == errno.ECONNREFUSED:
error_msg('was refused')
return
else:
raise
开发者ID:alkorzt,项目名称:pypy,代码行数:30,代码来源:test_socket_ssl.py
示例4: testPasswordProtectedSite
def testPasswordProtectedSite(self):
test_support.requires('network')
with test_support.transient_internet('mueblesmoraleda.com'):
url = 'http://mueblesmoraleda.com'
robots_url = url + "/robots.txt"
# First check the URL is usable for our purposes, since the
# test site is a bit flaky.
try:
urlopen(robots_url)
except HTTPError as e:
if e.code not in {401, 403}:
self.skipTest(
"%r should return a 401 or 403 HTTP error, not %r"
% (robots_url, e.code))
else:
self.skipTest(
"%r should return a 401 or 403 HTTP error, not succeed"
% (robots_url))
parser = robotparser.RobotFileParser()
parser.set_url(url)
try:
parser.read()
except IOError:
self.skipTest('%s is unavailable' % url)
self.assertEqual(parser.can_fetch("*", robots_url), False)
开发者ID:49476291,项目名称:android-plus-plus,代码行数:25,代码来源:test_robotparser.py
示例5: testPythonOrg
def testPythonOrg(self):
test_support.requires('network')
parser = robotparser.RobotFileParser(
"http://www.python.org/robots.txt")
parser.read()
self.assertTrue(parser.can_fetch("*",
"http://www.python.org/robots.txt"))
开发者ID:clamxyz,项目名称:LearnPythonTheHardWay,代码行数:7,代码来源:test_robotparser.py
示例6: test_main
def test_main():
test_support.requires("network")
test_support.run_unittest(AuthTests,
OtherNetworkTests,
CloseSocketTest,
TimeoutTest,
)
开发者ID:mxxu,项目名称:pyston,代码行数:7,代码来源:test_urllib2net.py
示例7: setUpClass
def setUpClass(cls):
requires("gui")
cls.root = Tk()
cls.TV = TV = tv.TextViewer
TV.transient = Func()
TV.grab_set = Func()
TV.wait_window = Func()
开发者ID:cimarieta,项目名称:usp,代码行数:7,代码来源:test_textview.py
示例8: test_bad_address
def test_bad_address(self):
# Make sure proper exception is raised when connecting to a bogus
# address.
# as indicated by the comment below, this might fail with some ISP,
# so we run the test only when -unetwork/-uall is specified to
# mitigate the problem a bit (see #17564)
test_support.requires('network')
self.assertRaises(IOError,
# Given that both VeriSign and various ISPs have in
# the past or are presently hijacking various invalid
# domain name requests in an attempt to boost traffic
# to their own sites, finding a domain name to use
# for this test is difficult. RFC2606 leads one to
# believe that '.invalid' should work, but experience
# seemed to indicate otherwise. Single character
# TLDs are likely to remain invalid, so this seems to
# be the best choice. The trailing '.' prevents a
# related problem: The normal DNS resolver appends
# the domain names from the search path if there is
# no '.' the end and, and if one of those domains
# implements a '*' rule a result is returned.
# However, none of this will prevent the test from
# failing if the ISP hijacks all invalid domain
# requests. The real solution would be to be able to
# parameterize the framework with a mock resolver.
urllib2.urlopen, "http://sadflkjsasf.i.nvali.d./")
开发者ID:j5shi,项目名称:Thruster,代码行数:27,代码来源:test_urllib2_localnet.py
示例9: test_main
def test_main():
if not test_support.due_to_ironpython_bug("http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=303467"):
test_support.requires('network')
with test_support.check_py3k_warnings(
("urllib.urlopen.. has been removed", DeprecationWarning)):
test_support.run_unittest(URLTimeoutTest,
urlopenNetworkTests,
urlretrieveNetworkTests)
开发者ID:BillyboyD,项目名称:main,代码行数:8,代码来源:test_urllibnet.py
示例10: runTest
def runTest(self):
test_support.requires('network')
# whole site is password-protected.
url = 'http://mueblesmoraleda.com'
parser = robotparser.RobotFileParser()
parser.set_url(url)
parser.read()
self.assertEqual(parser.can_fetch("*", url+"/robots.txt"), False)
开发者ID:DecipherOne,项目名称:Troglodyte,代码行数:8,代码来源:test_robotparser.py
示例11: test_main
def test_main():
if not test_support.due_to_ironpython_bug("http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=303467"):
test_support.requires("network")
test_support.run_unittest(AuthTests,
OtherNetworkTests,
CloseSocketTest,
TimeoutTest,
)
开发者ID:BillyboyD,项目名称:main,代码行数:8,代码来源:test_urllib2net.py
示例12: setUpClass
def setUpClass(cls):
if 'Tkinter' in str(Text):
requires('gui')
cls.tk = Tk()
cls.text = Text(cls.tk)
else:
cls.text = Text()
cls.auto_expand = AutoExpand(Dummy_Editwin(cls.text))
开发者ID:AtomicConductor,项目名称:conductor_client,代码行数:8,代码来源:test_autoexpand.py
示例13: testPythonOrg
def testPythonOrg(self):
support.requires('network')
with support.transient_internet('www.python.org'):
parser = robotparser.RobotFileParser(
"http://www.python.org/robots.txt")
parser.read()
self.assertTrue(
parser.can_fetch("*", "http://www.python.org/robots.txt"))
开发者ID:Stewori,项目名称:jython,代码行数:8,代码来源:test_robotparser.py
示例14: test_networked_trusted_by_default_cert
def test_networked_trusted_by_default_cert(self):
# Default settings: requires a valid cert from a trusted CA
test_support.requires('network')
with test_support.transient_internet('www.python.org'):
h = httplib.HTTPSConnection('www.python.org', 443)
h.request('GET', '/')
resp = h.getresponse()
content_type = resp.getheader('content-type')
self.assertIn('text/html', content_type)
开发者ID:Kelauni22,项目名称:Meeple,代码行数:9,代码来源:test_httplib.py
示例15: test_main
def test_main():
test_support.requires('network')
from warnings import filterwarnings, catch_warnings
with catch_warnings():
filterwarnings('ignore', '.*urllib\.urlopen.*Python 3.0',
DeprecationWarning)
test_support.run_unittest(URLTimeoutTest,
urlopenNetworkTests,
urlretrieveNetworkTests)
开发者ID:mullens,项目名称:khk-lights,代码行数:9,代码来源:test_urllibnet.py
示例16: setUpClass
def setUpClass(cls):
requires('gui')
cls.root = root = tk.Tk()
PyShell.fix_x11_paste(root)
cls.text = tk.Text(root)
cls.entry = tk.Entry(root)
cls.spin = tk.Spinbox(root)
root.clipboard_clear()
root.clipboard_append('two')
开发者ID:1187,项目名称:PokemonGo-DesktopMap,代码行数:9,代码来源:test_editmenu.py
示例17: test_networked
def test_networked(self):
# Default settings: requires a valid cert from a trusted CA
import ssl
test_support.requires('network')
with test_support.transient_internet('self-signed.pythontest.net'):
h = httplib.HTTPSConnection('self-signed.pythontest.net', 443)
with self.assertRaises(ssl.SSLError) as exc_info:
h.request('GET', '/')
self.assertEqual(exc_info.exception.reason, 'CERTIFICATE_VERIFY_FAILED')
开发者ID:Kelauni22,项目名称:Meeple,代码行数:9,代码来源:test_httplib.py
示例18: testPasswordProtectedSite
def testPasswordProtectedSite(self):
test_support.requires('network')
with test_support.transient_internet('mueblesmoraleda.com'):
url = 'http://mueblesmoraleda.com'
parser = robotparser.RobotFileParser()
parser.set_url(url)
try:
parser.read()
except IOError:
self.skipTest('%s is unavailable' % url)
self.assertEqual(parser.can_fetch("*", url+"/robots.txt"), False)
开发者ID:321boom,项目名称:The-Powder-Toy,代码行数:11,代码来源:test_robotparser.py
示例19: test_networked_noverification
def test_networked_noverification(self):
# Switch off cert verification
import ssl
test_support.requires('network')
with test_support.transient_internet('self-signed.pythontest.net'):
context = ssl._create_stdlib_context()
h = httplib.HTTPSConnection('self-signed.pythontest.net', 443,
context=context)
h.request('GET', '/')
resp = h.getresponse()
self.assertIn('nginx', resp.getheader('server'))
开发者ID:Kelauni22,项目名称:Meeple,代码行数:11,代码来源:test_httplib.py
示例20: testPasswordProtectedSite
def testPasswordProtectedSite(self):
test_support.requires('network')
# XXX it depends on an external resource which could be unavailable
url = 'http://mueblesmoraleda.com'
parser = robotparser.RobotFileParser()
parser.set_url(url)
try:
parser.read()
except IOError:
self.skipTest('%s is unavailable' % url)
self.assertEqual(parser.can_fetch("*", url+"/robots.txt"), False)
开发者ID:clamxyz,项目名称:LearnPythonTheHardWay,代码行数:11,代码来源:test_robotparser.py
注:本文中的test.test_support.requires函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论