<86>Nov 13 03:59:05 userdel[2876089]: delete user 'rooter' <86>Nov 13 03:59:05 userdel[2876089]: removed group 'rooter' owned by 'rooter' <86>Nov 13 03:59:05 userdel[2876089]: removed shadow group 'rooter' owned by 'rooter' <86>Nov 13 03:59:05 groupadd[2876127]: group added to /etc/group: name=rooter, GID=987 <86>Nov 13 03:59:05 groupadd[2876127]: group added to /etc/gshadow: name=rooter <86>Nov 13 03:59:05 groupadd[2876127]: new group: name=rooter, GID=987 <86>Nov 13 03:59:05 useradd[2876154]: new user: name=rooter, UID=987, GID=987, home=/root, shell=/bin/bash <86>Nov 13 03:59:05 userdel[2876188]: delete user 'builder' <86>Nov 13 03:59:05 userdel[2876188]: removed group 'builder' owned by 'builder' <86>Nov 13 03:59:05 userdel[2876188]: removed shadow group 'builder' owned by 'builder' <86>Nov 13 03:59:05 groupadd[2876223]: group added to /etc/group: name=builder, GID=988 <86>Nov 13 03:59:05 groupadd[2876223]: group added to /etc/gshadow: name=builder <86>Nov 13 03:59:05 groupadd[2876223]: new group: name=builder, GID=988 <86>Nov 13 03:59:05 useradd[2876242]: new user: name=builder, UID=988, GID=988, home=/usr/src, shell=/bin/bash /usr/src/in/srpm/python3-module-ClientForm-0.2.10-alt5.src.rpm: license not found in '/usr/share/license' directory: BSD-like <13>Nov 13 03:59:06 rpmi: libgdbm-1.8.3-alt10 sisyphus+278100.1600.1.1 1626059138 installed <13>Nov 13 03:59:06 rpmi: libpython-2.7.18-alt8 sisyphus+286676.100.1.1 1633726970 installed <13>Nov 13 03:59:06 rpmi: python2-base-2.7.18-alt8 sisyphus+286676.100.1.1 1633726970 installed <13>Nov 13 03:59:06 rpmi: libffi7-1:3.3-alt2 sisyphus+287337.160.5.1 1634396876 installed <13>Nov 13 03:59:06 rpmi: libexpat-2.2.10-alt1 sisyphus+276608.100.1.2 1625153360 installed <13>Nov 13 03:59:06 rpmi: libp11-kit-0.23.15-alt2 sisyphus+287552.300.2.1 1634541487 installed <13>Nov 13 03:59:06 rpmi: libtasn1-4.17.0-alt2 sisyphus+285706.100.1.1 1632328570 installed <13>Nov 13 03:59:06 rpmi: rpm-macros-alternatives-0.5.1-alt1 sisyphus+278157.100.2.1 1626055790 installed <13>Nov 13 03:59:06 rpmi: alternatives-0.5.1-alt1 sisyphus+278157.100.2.1 1626055790 installed <13>Nov 13 03:59:07 rpmi: ca-certificates-2021.10.06-alt1 sisyphus+286526.200.1.1 1633528578 installed <13>Nov 13 03:59:07 rpmi: ca-trust-0.1.2-alt1 sisyphus+233348.100.1.1 1561653823 installed <13>Nov 13 03:59:07 rpmi: p11-kit-trust-0.23.15-alt2 sisyphus+287552.300.2.1 1634541487 installed <13>Nov 13 03:59:07 rpmi: libcrypto1.1-1.1.1l-alt2 sisyphus+287339.100.1.1 1634383658 installed <13>Nov 13 03:59:07 rpmi: libssl1.1-1.1.1l-alt2 sisyphus+287339.100.1.1 1634383658 installed <13>Nov 13 03:59:07 rpmi: python-modules-encodings-2.7.18-alt8 sisyphus+286676.100.1.1 1633726970 installed <13>Nov 13 03:59:07 rpmi: python-modules-compiler-2.7.18-alt8 sisyphus+286676.100.1.1 1633726970 installed <13>Nov 13 03:59:07 rpmi: python-modules-email-2.7.18-alt8 sisyphus+286676.100.1.1 1633726970 installed <13>Nov 13 03:59:07 rpmi: python-modules-unittest-2.7.18-alt8 sisyphus+286676.100.1.1 1633726970 installed <13>Nov 13 03:59:07 rpmi: python-modules-2.7.18-alt8 sisyphus+286676.100.1.1 1633726970 installed <13>Nov 13 03:59:07 rpmi: python3-3.9.7-alt3 sisyphus+287552.400.2.1 1634543224 installed <13>Nov 13 03:59:07 rpmi: python3-base-3.9.7-alt3 sisyphus+287552.400.2.1 1634543224 installed <13>Nov 13 03:59:07 rpmi: tests-for-installed-python3-pkgs-0.1.17-alt1 sisyphus+271082.100.1.1 1619820927 installed <13>Nov 13 03:59:07 rpmi: python-modules-ctypes-2.7.18-alt8 sisyphus+286676.100.1.1 1633726970 installed <13>Nov 13 03:59:07 rpmi: python-modules-multiprocessing-2.7.18-alt8 sisyphus+286676.100.1.1 1633726970 installed <13>Nov 13 03:59:07 rpmi: python-modules-logging-2.7.18-alt8 sisyphus+286676.100.1.1 1633726970 installed <13>Nov 13 03:59:07 rpmi: python-tools-2to3-2.7.18-alt8 sisyphus+286676.100.1.1 1633726970 installed <13>Nov 13 03:59:07 rpmi: rpm-build-python3-0.1.17-alt1 sisyphus+271082.100.1.1 1619820927 installed Building target platforms: i586 Building for target i586 Wrote: /usr/src/in/nosrpm/python3-module-ClientForm-0.2.10-alt5.nosrc.rpm (w1.gzdio) <13>Nov 13 03:59:09 rpmi: python3-module-pkg_resources-1:58.4.0-alt1 sisyphus+288641.100.2.1 1635771382 installed <13>Nov 13 03:59:10 rpmi: libpython3-3.9.7-alt3 sisyphus+287552.400.2.1 1634543224 installed <13>Nov 13 03:59:10 rpmi: libncurses-6.3.20211106-alt1 sisyphus+289273.100.1.1 1636477039 installed <13>Nov 13 03:59:10 rpmi: libtinfo-devel-6.3.20211106-alt1 sisyphus+289273.100.1.1 1636477039 installed <13>Nov 13 03:59:10 rpmi: libncurses-devel-6.3.20211106-alt1 sisyphus+289273.100.1.1 1636477039 installed <13>Nov 13 03:59:10 rpmi: python3-dev-3.9.7-alt3 sisyphus+287552.400.2.1 1634543224 installed <13>Nov 13 03:59:10 rpmi: python3-module-setuptools-1:58.4.0-alt1 sisyphus+288641.100.2.1 1635771382 installed Installing python3-module-ClientForm-0.2.10-alt5.src.rpm Building target platforms: i586 Building for target i586 Executing(%prep): /bin/sh -e /usr/src/tmp/rpm-tmp.6449 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + rm -rf ClientForm-0.2.10 + echo 'Source #0 (ClientForm-0.2.10.tar.gz):' Source #0 (ClientForm-0.2.10.tar.gz): + /bin/gzip -dc /usr/src/RPM/SOURCES/ClientForm-0.2.10.tar.gz + /bin/tar -xf - + cd ClientForm-0.2.10 + /bin/chmod -c -Rf u+rwX,go-w . + exit 0 Executing(%build): /bin/sh -e /usr/src/tmp/rpm-tmp.13508 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd ClientForm-0.2.10 + find . -type f -name '*.py' -exec 2to3 -w -n '{}' + RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ./test/test_clientform.py --- ./test/test_clientform.py (original) +++ ./test/test_clientform.py (refactored) @@ -8,7 +8,7 @@ import unittest, string from unittest import TestCase -from cStringIO import StringIO +from io import StringIO import ClientForm from ClientForm import ControlNotFoundError, ItemNotFoundError, \ @@ -107,13 +107,13 @@ def test_unescape_charref(self): from ClientForm import unescape_charref, get_entitydefs - mdash_utf8 = u"\u2014".encode("utf-8") + mdash_utf8 = "\u2014".encode("utf-8") for ref, codepoint, utf8, latin1 in [ - ("38", 38, u"&".encode("utf-8"), "&"), + ("38", 38, "&".encode("utf-8"), "&"), ("x2014", 0x2014, mdash_utf8, "—"), ("8212", 8212, mdash_utf8, "—"), ]: - self.assertEqual(unescape_charref(ref, None), unichr(codepoint)) + self.assertEqual(unescape_charref(ref, None), chr(codepoint)) self.assertEqual(unescape_charref(ref, 'latin-1'), latin1) self.assertEqual(unescape_charref(ref, 'utf-8'), utf8) @@ -121,19 +121,19 @@ from ClientForm import get_entitydefs ed = get_entitydefs() for name, char in [ - ("&", u"&"), - ("<", u"<"), - (">", u">"), - ("—", u"\u2014"), - ("♠", u"\u2660"), + ("&", "&"), + ("<", "<"), + (">", ">"), + ("—", "\u2014"), + ("♠", "\u2660"), ]: self.assertEqual(ed[name], char) def test_unescape1(self): - import htmlentitydefs + import html.entities from ClientForm import unescape, get_entitydefs data = "& < — — —" - mdash_utf8 = u"\u2014".encode("utf-8") + mdash_utf8 = "\u2014".encode("utf-8") ue = unescape(data, get_entitydefs(), "utf-8") self.assertEqual("& < %s %s %s" % ((mdash_utf8,)*3), ue) @@ -160,7 +160,7 @@ self.assertEqual(unescape("&", {}), "&") for encoding, expected in [ - ("utf-8", u"&\u06aa\u2014\u2014".encode("utf-8")), + ("utf-8", "&\u06aa\u2014\u2014".encode("utf-8")), ("latin-1", "&ڪ——")]: self.assertEqual( expected, @@ -175,7 +175,7 @@ forms = ClientForm.ParseFile(file, "http://localhost/", backwards_compat=False, encoding="utf-8") form = forms[0] - test_string = "&"+(u"\u2014".encode('utf8')*3) + test_string = "&"+("\u2014".encode('utf8')*3) self.assertEqual(form.action, "http://localhost/"+test_string) control = form.find_control(type="textarea", nr=0) self.assertEqual(control.value, "val"+test_string) @@ -193,7 +193,7 @@ forms = ClientForm.ParseFileEx( f, "http://localhost/", encoding="utf-8") form = forms[1] - test_string = "&"+(u"\u2014".encode('utf8')*3) + test_string = "&"+("\u2014".encode('utf8')*3) control = form.find_control(nr=0) for ii in range(len(control.items)): item = control.items[ii] @@ -221,7 +221,7 @@ def testEmptyParse(self): forms = ClientForm.ParseFile(StringIO(""), "http://localhost", backwards_compat=False) - self.assert_(len(forms) == 0) + self.assertTrue(len(forms) == 0) def _forms(self): file = StringIO("""
@@ -236,8 +236,8 @@ def testParse(self): forms = self._forms() - self.assert_(len(forms) == 1) - self.assert_(forms[0]["firstname"] == "Gisle") + self.assertTrue(len(forms) == 1) + self.assertTrue(forms[0]["firstname"] == "Gisle") def testFillForm(self): forms = self._forms() @@ -249,8 +249,8 @@ return "POST" else: return "GET" - self.assert_(request_method(req) == "GET") - self.assert_(req.get_full_url() == "http://localhost/abc?firstname=Gisle+Aas") + self.assertTrue(request_method(req) == "GET") + self.assertTrue(req.get_full_url() == "http://localhost/abc?firstname=Gisle+Aas") def get_header(req, name): try: @@ -262,7 +262,7 @@ try: return req.header_items() except AttributeError: - return req.headers.items() + return list(req.headers.items()) class MockResponse: def __init__(self, f, url): @@ -289,7 +289,7 @@ ClientForm.ParseError, ClientForm.ParseFile, f, base_uri, backwards_compat=False, ) - self.assert_(issubclass(ClientForm.ParseError, sgmllib.SGMLParseError)) + self.assertTrue(issubclass(ClientForm.ParseError, sgmllib.SGMLParseError)) def test_unknown_control(self): f = StringIO( @@ -302,7 +302,7 @@ forms = ClientForm.ParseFile(f, base_uri, backwards_compat=False) form = forms[0] for ctl in form.controls: - self.assert_(isinstance(ctl, ClientForm.TextControl)) + self.assertTrue(isinstance(ctl, ClientForm.TextControl)) def test_ParseFileEx(self): # empty "outer form" (where the "outer form" is the form consisting of @@ -393,10 +393,10 @@ base_uri = "http://localhost/" try: ClientForm.ParseFile(f, base_uri, backwards_compat=False) - except ClientForm.ParseError, e: - self.assert_(e.base_uri == base_uri) + except ClientForm.ParseError as e: + self.assertTrue(e.base_uri == base_uri) else: - self.assert_(0) + self.assertTrue(0) def test_base_uri(self): # BASE element takes priority over document URI @@ -409,7 +409,7 @@ forms = ClientForm.ParseFile(file, "http://localhost/", backwards_compat=False) form = forms[0] - self.assert_(form.action == "http://example.com/abc") + self.assertTrue(form.action == "http://example.com/abc") file = StringIO( """ @@ -419,7 +419,7 @@ forms = ClientForm.ParseFile(file, "http://localhost/", backwards_compat=False) form = forms[0] - self.assert_(form.action == "http://localhost/abc") + self.assertTrue(form.action == "http://localhost/abc") def testTextarea(self): file = StringIO( @@ -440,19 +440,19 @@ """) forms = ClientForm.ParseFile(file, "http://localhost/", backwards_compat=False, encoding="utf-8") - self.assert_(len(forms) == 1) + self.assertTrue(len(forms) == 1) form = forms[0] - self.assert_(form.name is None) + self.assertTrue(form.name is None) self.assertEqual( form.action, - "http://localhost/abc&"+u"\u2014".encode('utf8')+"d") + "http://localhost/abc&"+"\u2014".encode('utf8')+"d") control = form.find_control(type="textarea", nr=0) - self.assert_(control.name is None) - self.assert_(control.value == "blah, blah,\r\nRhubarb.\r\n\r\n") + self.assertTrue(control.name is None) + self.assertTrue(control.value == "blah, blah,\r\nRhubarb.\r\n\r\n") empty_control = form.find_control(type="textarea", nr=1) - self.assert_(str(empty_control) == "=)>") - self.assert_(empty_control.value == "") + self.assertTrue(str(empty_control) == "=)>") + self.assertTrue(empty_control.value == "") entity_ctl = form.find_control(type="textarea", nr=2) self.assertEqual(entity_ctl.name, '"ta"') @@ -473,11 +473,11 @@ """) forms = ClientForm.ParseFile(file, "http://localhost/", backwards_compat=False) - self.assert_(len(forms) == 1) + self.assertTrue(len(forms) == 1) form = forms[0] entity_ctl = form.find_control(type="select") - self.assert_(entity_ctl.name == "foo") + self.assertTrue(entity_ctl.name == "foo") self.assertEqual(entity_ctl.value[0], "Hello testers & &blah; users!") hide_deprecations() @@ -505,14 +505,14 @@ forms = ClientForm.ParseFile(file, "http://localhost/", backwards_compat=False) form = forms[0] - self.assert_(form.name == "myform") + self.assertTrue(form.name == "myform") control = form.find_control(name="b") - self.assert_(control.type == "submitbutton") - self.assert_(control.value == "") - self.assert_(form.find_control("b2").type == "resetbutton") - self.assert_(form.find_control("b3").type == "buttonbutton") + self.assertTrue(control.type == "submitbutton") + self.assertTrue(control.value == "") + self.assertTrue(form.find_control("b2").type == "resetbutton") + self.assertTrue(form.find_control("b3").type == "buttonbutton") pairs = form.click_pairs() - self.assert_(pairs == [("moo", "cow"), ("b", "")]) + self.assertTrue(pairs == [("moo", "cow"), ("b", "")]) def testIsindex(self): file = StringIO( @@ -527,14 +527,14 @@ backwards_compat=False) form = forms[0] control = form.find_control(type="isindex") - self.assert_(control.type == "isindex") - self.assert_(control.name is None) - self.assert_(control.value == "") + self.assertTrue(control.type == "isindex") + self.assertTrue(control.name is None) + self.assertTrue(control.value == "") control.value = "some stuff" - self.assert_(form.click_pairs() == []) - self.assert_(form.click_request_data() == + self.assertTrue(form.click_pairs() == []) + self.assertTrue(form.click_request_data() == ("http://localhost/abc?some+stuff", None, [])) - self.assert_(form.click().get_full_url() == + self.assertTrue(form.click().get_full_url() == "http://localhost/abc?some+stuff") def testEmptySelect(self): @@ -551,11 +551,11 @@ form = forms[0] control0 = form.find_control(type="select", nr=0) control1 = form.find_control(type="select", nr=1) - self.assert_(str(control0) == "") - self.assert_(str(control1) == "") + self.assertTrue(str(control0) == "") + self.assertTrue(str(control1) == "") form.set_value([], "foo") self.assertRaises(ItemNotFoundError, form.set_value, ["oops"], "foo") - self.assert_(form.click_pairs() == []) + self.assertTrue(form.click_pairs() == []) # XXX figure out what to do in these sorts of cases ## def badSelect(self): @@ -654,7 +654,7 @@ forms = ClientForm.ParseFile(file, "http://localhost/", backwards_compat=False) form = forms[0] - self.assert_(form.controls[0].name is None) + self.assertTrue(form.controls[0].name is None) def testNamelessListItems(self): # XXX SELECT @@ -682,17 +682,17 @@ backwards_compat=False) form = forms[0] hide_deprecations() - self.assert_(form.possible_items("foo") == ["on"]) - self.assert_(form.possible_items("bar") == ["on"]) + self.assertTrue(form.possible_items("foo") == ["on"]) + self.assertTrue(form.possible_items("bar") == ["on"]) reset_deprecations() #self.assert_(form.possible_items("baz") == []) - self.assert_(form["foo"] == []) - self.assert_(form["bar"] == []) + self.assertTrue(form["foo"] == []) + self.assertTrue(form["bar"] == []) #self.assert_(form["baz"] == []) form["foo"] = ["on"] form["bar"] = ["on"] pairs = form.click_pairs() - self.assert_(pairs == [("foo", "on"), ("bar", "on"), ("submit", "")]) + self.assertTrue(pairs == [("foo", "on"), ("bar", "on"), ("submit", "")]) def testSingleSelectFixup(self): # HTML 4.01 section 17.6.1: single selection SELECT controls shouldn't @@ -764,9 +764,9 @@ backwards_compat=False) form = forms[0] control = form.find_control("a") - self.assert_(control.value == []) + self.assertTrue(control.value == []) single_control = form.find_control("b") - self.assert_(single_control.value == ["1"]) + self.assertTrue(single_control.value == ["1"]) file.seek(0) forms = ClientForm.ParseFile(file, "http://localhost/", @@ -774,9 +774,9 @@ form = forms[0] # select_default only affects *multiple* selection select controls control = form.find_control(type="select", nr=0) - self.assert_(control.value == ["1"]) + self.assertTrue(control.value == ["1"]) single_control = form.find_control(type="select", nr=1) - self.assert_(single_control.value == ["1"]) + self.assertTrue(single_control.value == ["1"]) def test_close_base_tag(self): # Benji York: a single newline immediately after a start tag is @@ -823,7 +823,7 @@ backwards_compat=False, ) form = forms[0] - self.assertEquals(len(form.controls), 2) + self.assertEqual(len(form.controls), 2) ctl = form.find_control(name="a", nr=0) self.assertEqual([item.name for item in ctl.items], ["b", "c"]) ctl = form.find_control(name="a", nr=1) @@ -858,7 +858,7 @@ def test_empty_document(self): forms = ClientForm.ParseFileEx(StringIO(""), "http://example.com/") - self.assertEquals(len(forms), 1) # just the "global form" + self.assertEqual(len(forms), 1) # just the "global form" def test_missing_closing_body_tag(self): # Even if there is no closing form or body tag, the last form on the @@ -867,8 +867,8 @@ StringIO(''), "http://example.com/", ) - self.assertEquals(len(forms), 2) - self.assertEquals(forms[1].name, "spam") + self.assertEqual(len(forms), 2) + self.assertEqual(forms[1].name, "spam") class DisabledTests(TestCase): @@ -977,48 +977,48 @@ control = get_control("foo") hide_deprecations() for name in 7, 8, 10: - self.assert_(control.get_item_disabled(str(name))) + self.assertTrue(control.get_item_disabled(str(name))) if not compat: # a disabled option is never "successful" (see above) so never # in value - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) # a disabled option always is always upset if you try to set it self.assertRaises(AttributeError, control.set, True, str(name)) - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) self.assertRaises(AttributeError, control.set, False, str(name)) - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) self.assertRaises(AttributeError, control.toggle, str(name)) - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) else: self.assertRaises(AttributeError, control.set, True, str(name)) control.set(False, str(name)) - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) control.set(False, str(name)) - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) self.assertRaises(AttributeError, control.toggle, str(name)) - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) self.assertRaises(AttributeError, control.set, True, str(name)) - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) control = get_control("foo") for name in 1, 2, 3, 4, 5, 6, 9: - self.assert_(not control.get_item_disabled(str(name))) + self.assertTrue(not control.get_item_disabled(str(name))) control.set(False, str(name)) - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) control.toggle(str(name)) - self.assert_(str(name) in control.value) + self.assertTrue(str(name) in control.value) control.set(True, str(name)) - self.assert_(str(name) in control.value) + self.assertTrue(str(name) in control.value) control.toggle(str(name)) - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) control = get_control("foo") - self.assert_(control.get_item_disabled("7")) + self.assertTrue(control.get_item_disabled("7")) control.set_item_disabled(True, "7") - self.assert_(control.get_item_disabled("7")) + self.assertTrue(control.get_item_disabled("7")) self.assertRaises(AttributeError, control.set, True, "7") control.set_item_disabled(False, "7") - self.assert_(not control.get_item_disabled("7")) + self.assertTrue(not control.get_item_disabled("7")) control.set(True, "7") control.set(False, "7") control.toggle("7") @@ -1051,50 +1051,50 @@ control = get_control("bar") hide_deprecations() for name in 7, 8, 10: - self.assert_(control.get_item_disabled(str(name))) + self.assertTrue(control.get_item_disabled(str(name))) if not compat: # a disabled option is never "successful" (see above) so never in # value - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) # a disabled option always is always upset if you try to set it self.assertRaises(AttributeError, control.set, True, str(name)) - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) self.assertRaises(AttributeError, control.set, False, str(name)) - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) self.assertRaises(AttributeError, control.toggle, str(name)) - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) else: self.assertRaises(AttributeError, control.set, True, str(name)) control.set(False, str(name)) - self.assert_(str(name) != control.value) + self.assertTrue(str(name) != control.value) control.set(False, str(name)) - self.assert_(str(name) != control.value) + self.assertTrue(str(name) != control.value) self.assertRaises(AttributeError, control.toggle, str(name)) - self.assert_(str(name) != control.value) + self.assertTrue(str(name) != control.value) self.assertRaises(AttributeError, control.set, True, str(name)) - self.assert_(str(name) != control.value) + self.assertTrue(str(name) != control.value) control = get_control("bar") for name in 1, 2, 3, 4, 5, 6, 9: - self.assert_(not control.get_item_disabled(str(name))) + self.assertTrue(not control.get_item_disabled(str(name))) control.set(False, str(name)) - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) control.toggle(str(name)) - self.assert_(str(name) == control.value[0]) + self.assertTrue(str(name) == control.value[0]) control.set(True, str(name)) - self.assert_(str(name) == control.value[0]) + self.assertTrue(str(name) == control.value[0]) control.toggle(str(name)) - self.assert_(str(name) not in control.value) + self.assertTrue(str(name) not in control.value) control = get_control("bar") - self.assert_(control.get_item_disabled("7")) + self.assertTrue(control.get_item_disabled("7")) control.set_item_disabled(True, "7") - self.assert_(control.get_item_disabled("7")) + self.assertTrue(control.get_item_disabled("7")) self.assertRaises(AttributeError, control.set, True, "7") self.assertEqual(control.value, value) control.set_item_disabled(False, "7") self.assertEqual(control.value, ["7"]) - self.assert_(not control.get_item_disabled("7")) + self.assertTrue(not control.get_item_disabled("7")) control.set(True, "7") control.set(False, "7") control.toggle("7") @@ -1168,7 +1168,7 @@ hide_deprecations() item = control.get_item_attrs("2") reset_deprecations() - self.assertEqual(bool(item.has_key("disabled")), item_disabled) + self.assertEqual(bool("disabled" in item), item_disabled) def bad_assign(value, control=control): control.value = value hide_deprecations() @@ -1190,9 +1190,9 @@ hide_deprecations() self.assertRaises(TypeError, control.set_item_disabled, "1") # by_label - self.assert_(not control.get_item_disabled("a", by_label=True)) + self.assertTrue(not control.get_item_disabled("a", by_label=True)) control.set_item_disabled(True, "a", by_label=True) - self.assert_(control.get_item_disabled("a", by_label=True)) + self.assertTrue(control.get_item_disabled("a", by_label=True)) reset_deprecations() def testDisabledRadio(self): @@ -1213,7 +1213,7 @@ # since all items are disabled, .fixup() should not select # anything - self.assertEquals( + self.assertEqual( [item.name for item in control.items if item.selected], [], ) @@ -1249,11 +1249,11 @@ ("bar", False, True), ("baz", False, True)]: control = form.find_control(name) - self.assert_(bool(control.disabled) == control_disabled) + self.assertTrue(bool(control.disabled) == control_disabled) hide_deprecations() item = control.get_item_attrs("2") - self.assert_(bool(item.has_key("disabled")) == item_disabled) - self.assert_(control.get_item_disabled("2") == item_disabled) + self.assertTrue(bool("disabled" in item) == item_disabled) + self.assertTrue(control.get_item_disabled("2") == item_disabled) def bad_assign(value, control=control): control.value = value if item_disabled: @@ -1271,10 +1271,10 @@ # missing disabled arg self.assertRaises(TypeError, control.set_item_disabled, "1") # by_label - self.failIf(control.get_item_disabled('a', by_label=True)) - self.assert_(not control.get_item_disabled("1")) + self.assertFalse(control.get_item_disabled('a', by_label=True)) + self.assertTrue(not control.get_item_disabled("1")) control.set_item_disabled(True, 'a', by_label=True) - self.assert_(control.get_item_disabled("1")) + self.assertTrue(control.get_item_disabled("1")) reset_deprecations() @@ -1287,52 +1287,52 @@ "id": "foo"} c = ClientForm.TextControl("texT", "ath_Uname", attrs) c.fixup() - self.assert_(c.type == "text") - self.assert_(c.name == "ath_Uname") - self.assert_(c.id == "foo") - self.assert_(c.value == "") - self.assert_(str(c) == "") - self.assert_(c.pairs() == [("ath_Uname", "")]) + self.assertTrue(c.type == "text") + self.assertTrue(c.name == "ath_Uname") + self.assertTrue(c.id == "foo") + self.assertTrue(c.value == "") + self.assertTrue(str(c) == "") + self.assertTrue(c.pairs() == [("ath_Uname", "")]) def bad_assign(c=c): c.type = "sometype" self.assertRaises(AttributeError, bad_assign) - self.assert_(c.type == "text") + self.assertTrue(c.type == "text") def bad_assign(c=c): c.name = "somename" self.assertRaises(AttributeError, bad_assign) - self.assert_(c.name == "ath_Uname") + self.assertTrue(c.name == "ath_Uname") c.value = "2" - self.assert_(c.value == "2") + self.assertTrue(c.value == "2") c.readonly = True self.assertRaises(AttributeError, c.clear) c.readonly = False c.clear() - self.assert_(c.value is None) + self.assertTrue(c.value is None) - self.assert_(c.pairs() == []) + self.assertTrue(c.pairs() == []) c.value = "2" # reset value... - self.assert_(str(c) == "") + self.assertTrue(str(c) == "") def bad_assign(c=c): c.value = ["foo"] self.assertRaises(TypeError, bad_assign) - self.assert_(c.value == "2") - self.assert_(not c.readonly) + self.assertTrue(c.value == "2") + self.assertTrue(not c.readonly) c.readonly = True def bad_assign(c=c): c.value = "foo" self.assertRaises(AttributeError, bad_assign) - self.assert_(c.value == "2") + self.assertTrue(c.value == "2") c.disabled = True - self.assert_(str(c) == + self.assertTrue(str(c) == "") c.readonly = False - self.assert_(str(c) == "") + self.assertTrue(str(c) == "") self.assertRaises(AttributeError, bad_assign) - self.assert_(c.value == "2") - self.assert_(c.pairs() == []) + self.assertTrue(c.value == "2") + self.assertTrue(c.pairs() == []) c.disabled = False - self.assert_(str(c) == "") - - self.assert_(c.attrs.has_key("maxlength")) + self.assertTrue(str(c) == "") + + self.assertTrue("maxlength" in c.attrs) for key in "name", "type", "value": - self.assert_(c.attrs.has_key(key)) + self.assertTrue(key in c.attrs) # initialisation of readonly and disabled attributes attrs["readonly"] = True @@ -1346,7 +1346,7 @@ self.assertRaises(AttributeError, bad_assign) del attrs["disabled"] c = ClientForm.TextControl("hidden", "ath_Uname", attrs) - self.assert_(c.readonly) + self.assertTrue(c.readonly) def bad_assign(c=c): c.value = "foo" self.assertRaises(AttributeError, bad_assign) @@ -1356,58 +1356,58 @@ c.add_file(fp) fp2 = StringIO() c.add_file(fp2, None, "fp2 file test") - self.assert_(str(c) == ', fp2 file test)>') + self.assertTrue(str(c) == ', fp2 file test)>') c.readonly = True self.assertRaises(AttributeError, c.clear) c.readonly = False c.clear() - self.assert_(str(c) == ')>') + self.assertTrue(str(c) == ')>') def testIsindexControl(self): attrs = {"type": "this is ignored", "prompt": ">>>"} c = ClientForm.IsindexControl("isIndex", None, attrs) c.fixup() - self.assert_(c.type == "isindex") - self.assert_(c.name is None) - self.assert_(c.value == "") - self.assert_(str(c) == "") - self.assert_(c.pairs() == []) + self.assertTrue(c.type == "isindex") + self.assertTrue(c.name is None) + self.assertTrue(c.value == "") + self.assertTrue(str(c) == "") + self.assertTrue(c.pairs() == []) def set_type(c=c): c.type = "sometype" self.assertRaises(AttributeError, set_type) - self.assert_(c.type == "isindex") + self.assertTrue(c.type == "isindex") def set_name(c=c): c.name = "somename" self.assertRaises(AttributeError, set_name) def set_value(value, c=c): c.value = value self.assertRaises(TypeError, set_value, [None]) - self.assert_(c.name is None) + self.assertTrue(c.name is None) c.value = "2" - self.assert_(c.value == "2") - self.assert_(str(c) == "") + self.assertTrue(c.value == "2") + self.assertTrue(str(c) == "") c.disabled = True - self.assert_(str(c) == "") + self.assertTrue(str(c) == "") self.assertRaises(AttributeError, set_value, "foo") - self.assert_(c.value == "2") - self.assert_(c.pairs() == []) + self.assertTrue(c.value == "2") + self.assertTrue(c.pairs() == []) c.readonly = True - self.assert_(str(c) == "") + self.assertTrue(str(c) == "") self.assertRaises(AttributeError, set_value, "foo") c.disabled = False - self.assert_(str(c) == "") + self.assertTrue(str(c) == "") self.assertRaises(AttributeError, set_value, "foo") c.readonly = False - self.assert_(str(c) == "") - - self.assert_(c.attrs.has_key("type")) - self.assert_(c.attrs.has_key("prompt")) - self.assert_(c.attrs["prompt"] == ">>>") + self.assertTrue(str(c) == "") + + self.assertTrue("type" in c.attrs) + self.assertTrue("prompt" in c.attrs) + self.assertTrue(c.attrs["prompt"] == ">>>") for key in "name", "value": - self.assert_(not c.attrs.has_key(key)) + self.assertTrue(key not in c.attrs) c.value = "foo 1 bar 2" class FakeForm: action = "http://localhost/" form = FakeForm() - self.assert_(c._click(form, (1,1), "request_data") == + self.assertTrue(c._click(form, (1,1), "request_data") == ("http://localhost/?foo+1+bar+2", None, [])) c.value = "foo 1 bar 2" @@ -1415,22 +1415,22 @@ self.assertRaises(AttributeError, c.clear) c.readonly = False c.clear() - self.assert_(c.value is None) + self.assertTrue(c.value is None) def testIgnoreControl(self): attrs = {"type": "this is ignored"} c = ClientForm.IgnoreControl("reset", None, attrs) - self.assert_(c.type == "reset") - self.assert_(c.value is None) - self.assert_(str(c) == "=)>") + self.assertTrue(c.type == "reset") + self.assertTrue(c.value is None) + self.assertTrue(str(c) == "=)>") def set_value(value, c=c): c.value = value self.assertRaises(AttributeError, set_value, "foo") - self.assert_(c.value is None) + self.assertTrue(c.value is None) # this is correct, but silly; basically nothing should happen c.clear() - self.assert_(c.value is None) + self.assertTrue(c.value is None) def testSubmitControl(self): attrs = {"type": "this is ignored", @@ -1438,16 +1438,16 @@ "value": "value_value", "img": "foo.gif"} c = ClientForm.SubmitControl("submit", "name_value", attrs) - self.assert_(c.type == "submit") - self.assert_(c.name == "name_value") - self.assert_(c.value == "value_value") - self.assert_(str(c) == "") + self.assertTrue(c.type == "submit") + self.assertTrue(c.name == "name_value") + self.assertTrue(c.value == "value_value") + self.assertTrue(str(c) == "") c.readonly = True self.assertRaises(AttributeError, c.clear) c.readonly = False c.clear() - self.assert_(c.value is None) + self.assertTrue(c.value is None) c.value = "value_value" c.readonly = True @@ -1455,62 +1455,62 @@ self.assertRaises(TypeError, set_value, ["foo"]) c.disabled = True self.assertRaises(AttributeError, set_value, "value_value") - self.assert_(str(c) == "") c.disabled = False c.readonly = False set_value("value_value") - self.assert_(str(c) == "") + self.assertTrue(str(c) == "") c.readonly = True # click on button form = ClientForm.HTMLForm("http://foo.bar.com/") c.add_to_form(form) - self.assert_(c.pairs() == []) + self.assertTrue(c.pairs() == []) pairs = c._click(form, (1,1), "pairs") request = c._click(form, (1,1), "request") data = c._click(form, (1,1), "request_data") - self.assert_(c.pairs() == []) - self.assert_(pairs == [("name_value", "value_value")]) - self.assert_(request.get_full_url() == + self.assertTrue(c.pairs() == []) + self.assertTrue(pairs == [("name_value", "value_value")]) + self.assertTrue(request.get_full_url() == "http://foo.bar.com/?name_value=value_value") - self.assert_(data == + self.assertTrue(data == ("http://foo.bar.com/?name_value=value_value", None, [])) c.disabled = True pairs = c._click(form, (1,1), "pairs") request = c._click(form, (1,1), "request") data = c._click(form, (1,1), "request_data") - self.assert_(pairs == []) + self.assertTrue(pairs == []) # XXX not sure if should have '?' on end of this URL, or if it really matters... - self.assert_(request.get_full_url() == "http://foo.bar.com/") - self.assert_(data == ("http://foo.bar.com/", None, [])) + self.assertTrue(request.get_full_url() == "http://foo.bar.com/") + self.assertTrue(data == ("http://foo.bar.com/", None, [])) def testImageControl(self): attrs = {"type": "this is ignored", "name": "name_value", "img": "foo.gif"} c = ClientForm.ImageControl("image", "name_value", attrs, index=0) - self.assert_(c.type == "image") - self.assert_(c.name == "name_value") - self.assert_(c.value == "") - self.assert_(str(c) == "") + self.assertTrue(c.type == "image") + self.assertTrue(c.name == "name_value") + self.assertTrue(c.value == "") + self.assertTrue(str(c) == "") c.readonly = True self.assertRaises(AttributeError, c.clear) c.readonly = False c.clear() - self.assert_(c.value is None) + self.assertTrue(c.value is None) c.value = "" # click, at coordinate (0, 55), on image form = ClientForm.HTMLForm("http://foo.bar.com/") c.add_to_form(form) - self.assert_(c.pairs() == []) + self.assertTrue(c.pairs() == []) request = c._click(form, (0, 55), "request") - self.assert_(c.pairs() == []) - self.assert_(request.get_full_url() == + self.assertTrue(c.pairs() == []) + self.assertTrue(request.get_full_url() == "http://foo.bar.com/?name_value.x=0&name_value.y=55") - self.assert_(c._click(form, (0,55), return_type="request_data") == + self.assertTrue(c._click(form, (0,55), return_type="request_data") == ("http://foo.bar.com/?name_value.x=0&name_value.y=55", None, [])) c.value = "blah" @@ -1520,17 +1520,17 @@ c.disabled = True self.assertEqual(c.value, "blah") - self.assert_(str(c) == "") + self.assertTrue(str(c) == "") def set_value(value, c=c): c.value = value self.assertRaises(AttributeError, set_value, "blah") - self.assert_(c._click(form, (1,1), return_type="pairs") == []) + self.assertTrue(c._click(form, (1,1), return_type="pairs") == []) c.readonly = True - self.assert_(str(c) == "") self.assertRaises(AttributeError, set_value, "blah") - self.assert_(c._click(form, (1,1), return_type="pairs") == []) + self.assertTrue(c._click(form, (1,1), return_type="pairs") == []) c.disabled = c.readonly = False - self.assert_(c._click(form, (1,1), return_type="pairs") == + self.assertTrue(c._click(form, (1,1), return_type="pairs") == [("name_value.x", "1"), ("name_value.y", "1"), ('name_value', 'blah')]) @@ -1544,18 +1544,18 @@ c = ClientForm.CheckboxControl("checkbox", "name_value", attrs) c.add_to_form(form) c.fixup() - self.assert_(c.type == "checkbox") - self.assert_(c.name == "name_value") - self.assert_(c.value == []) - hide_deprecations() - self.assert_(c.possible_items() == ["value_value"]) + self.assertTrue(c.type == "checkbox") + self.assertTrue(c.name == "name_value") + self.assertTrue(c.value == []) + hide_deprecations() + self.assertTrue(c.possible_items() == ["value_value"]) reset_deprecations() def set_type(c=c): c.type = "sometype" self.assertRaises(AttributeError, set_type) - self.assert_(c.type == "checkbox") + self.assertTrue(c.type == "checkbox") def set_name(c=c): c.name = "somename" self.assertRaises(AttributeError, set_name) - self.assert_(c.name == "name_value") + self.assertTrue(c.name == "name_value") # construct larger list from length-1 lists c = ClientForm.CheckboxControl("checkbox", "name_value", attrs) @@ -1566,88 +1566,88 @@ c.merge_control(c2) c.add_to_form(form) c.fixup() - self.assert_(str(c) == "") hide_deprecations() - self.assert_(c.possible_items() == ["value_value", "value_value2"]) + self.assertTrue(c.possible_items() == ["value_value", "value_value2"]) attrs = c.get_item_attrs("value_value") for key in "alt", "name", "value", "type": - self.assert_(attrs.has_key(key)) + self.assertTrue(key in attrs) self.assertRaises(ItemNotFoundError, c.get_item_attrs, "oops") reset_deprecations() def set_value(value, c=c): c.value = value c.value = ["value_value", "value_value2"] - self.assert_(c.value == ["value_value", "value_value2"]) + self.assertTrue(c.value == ["value_value", "value_value2"]) c.value = ["value_value"] self.assertEqual(c.value, ["value_value"]) self.assertRaises(ItemNotFoundError, set_value, ["oops"]) self.assertRaises(TypeError, set_value, "value_value") c.value = ["value_value2"] - self.assert_(c.value == ["value_value2"]) + self.assertTrue(c.value == ["value_value2"]) hide_deprecations() c.toggle("value_value") - self.assert_(c.value == ["value_value", "value_value2"]) + self.assertTrue(c.value == ["value_value", "value_value2"]) c.toggle("value_value2") reset_deprecations() - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) hide_deprecations() self.assertRaises(ItemNotFoundError, c.toggle, "oops") reset_deprecations() - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) c.readonly = True self.assertRaises(AttributeError, c.clear) c.readonly = False c.clear() - self.assert_(c.value == []) + self.assertTrue(c.value == []) # set hide_deprecations() c.set(True, "value_value") - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) c.set(True, "value_value2") - self.assert_(c.value == ["value_value", "value_value2"]) + self.assertTrue(c.value == ["value_value", "value_value2"]) c.set(True, "value_value2") - self.assert_(c.value == ["value_value", "value_value2"]) + self.assertTrue(c.value == ["value_value", "value_value2"]) c.set(False, "value_value2") - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) c.set(False, "value_value2") - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) self.assertRaises(ItemNotFoundError, c.set, True, "oops") self.assertRaises(TypeError, c.set, True, ["value_value"]) self.assertRaises(ItemNotFoundError, c.set, False, "oops") self.assertRaises(TypeError, c.set, False, ["value_value"]) reset_deprecations() - self.assert_(str(c) == "") c.disabled = True self.assertRaises(AttributeError, set_value, ["value_value"]) - self.assert_(str(c) == "") - self.assert_(c.value == ["value_value"]) - self.assert_(c.pairs() == []) + self.assertTrue(c.value == ["value_value"]) + self.assertTrue(c.pairs() == []) c.readonly = True self.assertRaises(AttributeError, set_value, ["value_value"]) - self.assert_(str(c) == "") - self.assert_(c.value == ["value_value"]) - self.assert_(c.pairs() == []) + self.assertTrue(c.value == ["value_value"]) + self.assertTrue(c.pairs() == []) c.disabled = False - self.assert_(str(c) == "") self.assertRaises(AttributeError, set_value, ["value_value"]) - self.assert_(c.value == ["value_value"]) - self.assert_(c.pairs() == [("name_value", "value_value")]) + self.assertTrue(c.value == ["value_value"]) + self.assertTrue(c.pairs() == [("name_value", "value_value")]) c.readonly = False c.value = [] - self.assert_(c.value == []) + self.assertTrue(c.value == []) def testSelectControlMultiple(self): import copy @@ -1666,20 +1666,20 @@ c = ClientForm.SelectControl("select", "select_name", attrs) c.add_to_form(form) c.fixup() - self.assert_(c.type == "select") - self.assert_(c.name == "select_name") - self.assert_(c.value == []) - hide_deprecations() - self.assert_(c.possible_items() == ["value_value"]) - reset_deprecations() - self.assert_(c.attrs.has_key("name")) - self.assert_(c.attrs.has_key("type")) - self.assert_(c.attrs["alt"] == "alt_text") + self.assertTrue(c.type == "select") + self.assertTrue(c.name == "select_name") + self.assertTrue(c.value == []) + hide_deprecations() + self.assertTrue(c.possible_items() == ["value_value"]) + reset_deprecations() + self.assertTrue("name" in c.attrs) + self.assertTrue("type" in c.attrs) + self.assertTrue(c.attrs["alt"] == "alt_text") # ... and with RFC 1866 default selection c = ClientForm.SelectControl("select", "select_name", attrs, select_default=True) c.add_to_form(form) c.fixup() - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) # construct larger list from length-1 lists c = ClientForm.SelectControl("select", "select_name", attrs) @@ -1690,28 +1690,28 @@ c.merge_control(c2) c.add_to_form(form) c.fixup() - self.assert_(str(c) == "") hide_deprecations() - self.assert_(c.possible_items() == ["value_value", "value_value2"]) + self.assertTrue(c.possible_items() == ["value_value", "value_value2"]) # get_item_attrs attrs3 = c.get_item_attrs("value_value") reset_deprecations() - self.assert_(attrs3.has_key("alt")) - self.assert_(not attrs3.has_key("multiple")) + self.assertTrue("alt" in attrs3) + self.assertTrue("multiple" not in attrs3) # HTML attributes dictionary should have been copied by ListControl # constructor. attrs["new_attr"] = "new" attrs2["new_attr2"] = "new2" for key in ("new_attr", "new_attr2"): - self.assert_(not attrs3.has_key(key)) + self.assertTrue(key not in attrs3) hide_deprecations() self.assertRaises(ItemNotFoundError, c.get_item_attrs, "oops") reset_deprecations() c.value = ["value_value", "value_value2"] - self.assert_(c.value == ["value_value", "value_value2"]) + self.assertTrue(c.value == ["value_value", "value_value2"]) c.value = ["value_value"] self.assertEqual(c.value, ["value_value"]) def set_value(value, c=c): c.value = value @@ -1719,42 +1719,42 @@ self.assertRaises(TypeError, set_value, "value_value") self.assertRaises(TypeError, set_value, None) c.value = ["value_value2"] - self.assert_(c.value == ["value_value2"]) + self.assertTrue(c.value == ["value_value2"]) hide_deprecations() c.toggle("value_value") - self.assert_(c.value == ["value_value", "value_value2"]) + self.assertTrue(c.value == ["value_value", "value_value2"]) c.toggle("value_value2") - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) self.assertRaises(ItemNotFoundError, c.toggle, "oops") - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) reset_deprecations() c.readonly = True self.assertRaises(AttributeError, c.clear) c.readonly = False c.clear() - self.assert_(c.value == []) + self.assertTrue(c.value == []) # test ordering of items c.value = ["value_value2", "value_value"] - self.assert_(c.value == ["value_value", "value_value2"]) + self.assertTrue(c.value == ["value_value", "value_value2"]) # set hide_deprecations() c.set(True, "value_value") - self.assert_(c.value == ["value_value", "value_value2"]) + self.assertTrue(c.value == ["value_value", "value_value2"]) c.set(True, "value_value2") - self.assert_(c.value == ["value_value", "value_value2"]) + self.assertTrue(c.value == ["value_value", "value_value2"]) c.set(False, "value_value") - self.assert_(c.value == ["value_value2"]) + self.assertTrue(c.value == ["value_value2"]) c.set(False, "value_value") - self.assert_(c.value == ["value_value2"]) + self.assertTrue(c.value == ["value_value2"]) self.assertRaises(ItemNotFoundError, c.set, True, "oops") self.assertRaises(TypeError, c.set, True, ["value_value"]) self.assertRaises(ItemNotFoundError, c.set, False, "oops") self.assertRaises(TypeError, c.set, False, ["value_value"]) reset_deprecations() c.value = [] - self.assert_(c.value == []) + self.assertTrue(c.value == []) def testSelectControlMultiple_label(self): import ClientForm @@ -1797,66 +1797,66 @@ c.fixup() hide_deprecations() - self.assert_(c.possible_items() == ["0", "1", "2000"]) - self.assert_(c.possible_items(by_label=True) == + self.assertTrue(c.possible_items() == ["0", "1", "2000"]) + self.assertTrue(c.possible_items(by_label=True) == ["2002", "2001", "2000"]) - self.assert_(c.value == []) + self.assertTrue(c.value == []) c.toggle("2002", by_label=True) - self.assert_(c.value == ["0"]) + self.assertTrue(c.value == ["0"]) c.toggle("0") - self.assert_(c.value == []) + self.assertTrue(c.value == []) c.toggle("0") - self.assert_(c.value == ["0"]) - self.assert_(c.get_value_by_label() == ["2002"]) + self.assertTrue(c.value == ["0"]) + self.assertTrue(c.get_value_by_label() == ["2002"]) c.toggle("2002", by_label=True) self.assertRaises(ItemNotFoundError, c.toggle, "blah", by_label=True) - self.assert_(c.value == []) + self.assertTrue(c.value == []) c.toggle("2000") reset_deprecations() - self.assert_(c.value == ["2000"]) - self.assert_(c.get_value_by_label() == ["2000"]) + self.assertTrue(c.value == ["2000"]) + self.assertTrue(c.get_value_by_label() == ["2000"]) def set_value(value, c=c): c.value = value self.assertRaises(ItemNotFoundError, set_value, ["2002"]) self.assertRaises(TypeError, set_value, "1") self.assertRaises(TypeError, set_value, None) - self.assert_(c.value == ["2000"]) + self.assertTrue(c.value == ["2000"]) c.value = ["0"] self.assertEqual(c.value, ["0"]) c.value = [] self.assertRaises(TypeError, c.set_value_by_label, "2002") c.set_value_by_label(["2002"]) - self.assert_(c.value == ["0"]) - self.assert_(c.get_value_by_label() == ["2002"]) + self.assertTrue(c.value == ["0"]) + self.assertTrue(c.get_value_by_label() == ["2002"]) c.set_value_by_label(["2000"]) - self.assert_(c.value == ["2000"]) - self.assert_(c.get_value_by_label() == ["2000"]) + self.assertTrue(c.value == ["2000"]) + self.assertTrue(c.get_value_by_label() == ["2000"]) c.set_value_by_label(["2000", "2002"]) - self.assert_(c.value == ["0", "2000"]) - self.assert_(c.get_value_by_label() == ["2002", "2000"]) + self.assertTrue(c.value == ["0", "2000"]) + self.assertTrue(c.get_value_by_label() == ["2002", "2000"]) c.readonly = True self.assertRaises(AttributeError, c.clear) c.readonly = False c.clear() - self.assert_(c.value == []) + self.assertTrue(c.value == []) c.set_value_by_label(["2000", "2002"]) hide_deprecations() c.set(False, "2002", by_label=True) - self.assert_(c.get_value_by_label() == c.value == ["2000"]) + self.assertTrue(c.get_value_by_label() == c.value == ["2000"]) c.set(False, "2002", by_label=True) - self.assert_(c.get_value_by_label() == c.value == ["2000"]) + self.assertTrue(c.get_value_by_label() == c.value == ["2000"]) c.set(True, "2002", by_label=True) - self.assert_(c.get_value_by_label() == ["2002", "2000"]) - self.assert_(c.value == ["0", "2000"]) + self.assertTrue(c.get_value_by_label() == ["2002", "2000"]) + self.assertTrue(c.value == ["0", "2000"]) c.set(False, "2000", by_label=True) - self.assert_(c.get_value_by_label() == ["2002"]) - self.assert_(c.value == ["0"]) + self.assertTrue(c.get_value_by_label() == ["2002"]) + self.assertTrue(c.value == ["0"]) c.set(True, "2001", by_label=True) - self.assert_(c.get_value_by_label() == ["2002", "2001"]) - self.assert_(c.value == ["0", "1"]) + self.assertTrue(c.get_value_by_label() == ["2002", "2001"]) + self.assertTrue(c.value == ["0", "1"]) self.assertRaises(ItemNotFoundError, c.set, True, "blah", by_label=True) self.assertRaises(ItemNotFoundError, c.set, @@ -1901,8 +1901,8 @@ c.fixup() hide_deprecations() - self.assert_(c.possible_items() == ["0", "1", "2000"]) - self.assert_(c.possible_items(by_label=True) == + self.assertTrue(c.possible_items() == ["0", "1", "2000"]) + self.assertTrue(c.possible_items(by_label=True) == ["2002", "2001", "2000"]) reset_deprecations() @@ -1910,11 +1910,11 @@ self.assertRaises(ItemNotFoundError, set_value, ["2002"]) self.assertRaises(TypeError, set_value, "1") self.assertRaises(TypeError, set_value, None) - self.assert_(c.value == ["0"]) + self.assertTrue(c.value == ["0"]) c.value = [] - self.assert_(c.value == []) + self.assertTrue(c.value == []) c.value = ["0"] - self.assert_(c.value == ["0"]) + self.assertTrue(c.value == ["0"]) c.value = [] self.assertRaises(TypeError, c.set_value_by_label, "2002") @@ -1922,17 +1922,17 @@ ["2000", "2001"]) self.assertRaises(ItemNotFoundError, c.set_value_by_label, ["foo"]) c.set_value_by_label(["2002"]) - self.assert_(c.value == ["0"]) - self.assert_(c.get_value_by_label() == ["2002"]) + self.assertTrue(c.value == ["0"]) + self.assertTrue(c.get_value_by_label() == ["2002"]) c.set_value_by_label(["2000"]) - self.assert_(c.value == ["2000"]) - self.assert_(c.get_value_by_label() == ["2000"]) + self.assertTrue(c.value == ["2000"]) + self.assertTrue(c.get_value_by_label() == ["2000"]) c.readonly = True self.assertRaises(AttributeError, c.clear) c.readonly = False c.clear() - self.assert_(c.value == []) + self.assertTrue(c.value == []) def testSelectControlSingle(self): attrs = {"type": "this is ignored", @@ -1948,21 +1948,21 @@ form = DummyForm() c.add_to_form(form) c.fixup() - self.assert_(c.type == "select") - self.assert_(c.name == "select_name") - self.assert_(c.value == ["value_value"]) - hide_deprecations() - self.assert_(c.possible_items() == ["value_value"]) - reset_deprecations() - self.assert_(c.attrs.has_key("name")) - self.assert_(c.attrs.has_key("type")) - self.assert_(c.attrs["alt"] == "alt_text") + self.assertTrue(c.type == "select") + self.assertTrue(c.name == "select_name") + self.assertTrue(c.value == ["value_value"]) + hide_deprecations() + self.assertTrue(c.possible_items() == ["value_value"]) + reset_deprecations() + self.assertTrue("name" in c.attrs) + self.assertTrue("type" in c.attrs) + self.assertTrue(c.attrs["alt"] == "alt_text") # ...and RFC 1866 behaviour are identical (unlike multiple SELECT). c = ClientForm.SelectControl("select", "select_name", attrs, select_default=1) c.add_to_form(form) c.fixup() - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) # construct larger list from length-1 lists c = ClientForm.SelectControl("select", "select_name", attrs) @@ -1972,18 +1972,18 @@ c.merge_control(c2) c.add_to_form(form) c.fixup() - self.assert_(str(c) == "") c.value = [] - self.assert_(c.value == []) - self.assert_(str(c) == "") c.value = ["value_value"] - self.assert_(c.value == ["value_value"]) - self.assert_(str(c) == "") hide_deprecations() - self.assert_(c.possible_items() == ["value_value", "value_value2"]) + self.assertTrue(c.possible_items() == ["value_value", "value_value2"]) reset_deprecations() def set_value(value, c=c): c.value = value @@ -1992,45 +1992,45 @@ self.assertRaises(TypeError, set_value, "value_value") self.assertRaises(TypeError, set_value, None) c.value = ["value_value2"] - self.assert_(c.value == ["value_value2"]) + self.assertTrue(c.value == ["value_value2"]) c.value = ["value_value"] - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) self.assertRaises(ItemNotFoundError, set_value, ["oops"]) - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) hide_deprecations() c.toggle("value_value") self.assertRaises(ItemNotFoundError, c.toggle, "oops") self.assertRaises(TypeError, c.toggle, ["oops"]) reset_deprecations() - self.assert_(c.value == []) + self.assertTrue(c.value == []) c.value = ["value_value"] - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) # nothing selected is allowed c.value = [] - self.assert_(c.value == []) + self.assertTrue(c.value == []) hide_deprecations() c.set(True, "value_value") - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) c.readonly = True self.assertRaises(AttributeError, c.clear) c.readonly = False c.clear() - self.assert_(c.value == []) + self.assertTrue(c.value == []) # set c.set(True, "value_value") - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) c.set(True, "value_value") - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) c.set(True, "value_value2") - self.assert_(c.value == ["value_value2"]) + self.assertTrue(c.value == ["value_value2"]) c.set(False, "value_value") - self.assert_("value_value2") + self.assertTrue("value_value2") c.set(False, "value_value2") - self.assert_(c.value == []) + self.assertTrue(c.value == []) c.set(False, "value_value2") - self.assert_(c.value == []) + self.assertTrue(c.value == []) self.assertRaises(ItemNotFoundError, c.set, True, "oops") self.assertRaises(TypeError, c.set, True, ["value_value"]) self.assertRaises(ItemNotFoundError, c.set, False, "oops") @@ -2047,19 +2047,19 @@ form = DummyForm() c.add_to_form(form) c.fixup() - self.assert_(c.type == "radio") - self.assert_(c.name == "name_value") - self.assert_(c.id == "blah") - self.assert_(c.value == []) - hide_deprecations() - self.assert_(c.possible_items() == ["value_value"]) + self.assertTrue(c.type == "radio") + self.assertTrue(c.name == "name_value") + self.assertTrue(c.id == "blah") + self.assertTrue(c.value == []) + hide_deprecations() + self.assertTrue(c.possible_items() == ["value_value"]) reset_deprecations() # ...and RFC 1866 behaviour c = ClientForm.RadioControl("radio", "name_value", attrs, select_default=True) c.add_to_form(form) c.fixup() - self.assert_(c.value == ["value_value"]) + self.assertTrue(c.value == ["value_value"]) # construct larger list from length-1 lists c = ClientForm.RadioControl("radio", "name_value", attrs, @@ -2071,10 +2071,10 @@ c.merge_control(c2) c.add_to_form(form) c.fixup() - self.assert_(str(c) == "") hide_deprecations() - self.assert_(c.possible_items() == ["value_value", "value_value2"]) + self.assertTrue(c.possible_items() == ["value_value", "value_value2"]) reset_deprecations() def set_value(value, c=c): c.value = value @@ -2117,7 +2117,7 @@ c.set(True, "value_value2") self.assertEqual(c.value, ["value_value2"]) c.set(False, "value_value") - self.assert_("value_value2") + self.assertTrue("value_value2") c.set(False, "value_value2") self.assertEqual(c.value, []) c.set(False, "value_value2") @@ -2159,17 +2159,17 @@ ['value_value', 'value_value', 'another_value']) reset_deprecations() self.assertEqual(c1.value, ['value_value']) - self.failIf(c1.items[0].selected) - self.failUnless(c1.items[1].selected) - self.failIf(c1.items[2].selected) + self.assertFalse(c1.items[0].selected) + self.assertTrue(c1.items[1].selected) + self.assertFalse(c1.items[2].selected) c1.value = ['value_value'] # should be no change - self.failUnless(c1.items[1].selected) + self.assertTrue(c1.items[1].selected) self.assertEqual(c1.value, ['value_value']) c1.value = ['another_value'] - self.failUnless(c1.items[2].selected) + self.assertTrue(c1.items[2].selected) self.assertEqual(c1.value, ['another_value']) c1.value = ['value_value'] - self.failUnless(c1.items[0].selected) + self.assertTrue(c1.items[0].selected) self.assertEqual(c1.value, ['value_value']) # id labels @@ -2396,8 +2396,8 @@ form = ClientForm.ParseFile(file, "http://blah/", backwards_compat=False)[0] self.assertRaises(ControlNotFoundError, form.click, nr=2) - self.assert_(form.click().get_full_url() == "http://blah/abc?foo=") - self.assert_(form.click(name="bar").get_full_url() == "http://blah/abc?bar=") + self.assertTrue(form.click().get_full_url() == "http://blah/abc?foo=") + self.assertTrue(form.click(name="bar").get_full_url() == "http://blah/abc?bar=") for method in ["GET", "POST"]: file = StringIO( @@ -2413,15 +2413,15 @@ url = "http://blah/abc?foo=" else: url = "http://blah/abc?bang=whizz" - self.assert_(form.click().get_full_url() == url) + self.assertTrue(form.click().get_full_url() == url) def testAuth(self): file = open("./testdata/Auth.html", "r") forms = ClientForm.ParseFile(file, self.base_uri, backwards_compat=False) - self.assert_(len(forms) == 1) + self.assertTrue(len(forms) == 1) form = forms[0] - self.assert_(form.action == + self.assertTrue(form.action == "http://auth.athensams.net/" "?ath_returl=%22http%3A%2F%2Ftame.mimas.ac.uk%2Fisicgi" "%2FWOS-login.cgi%22&ath_dspid=MIMAS.WOS") @@ -2440,17 +2440,17 @@ for i in range(len(keys)): key = keys[i] c = form.find_control(key) - self.assert_(c.value == values[i]) - self.assert_(c.type == types[i]) + self.assertTrue(c.value == values[i]) + self.assertTrue(c.type == types[i]) c = form.find_control(type="image") - self.assert_(c.name is None) - self.assert_(c.value == "") - self.assert_(c.type == "image") + self.assertTrue(c.name is None) + self.assertTrue(c.value == "") + self.assertTrue(c.type == "image") form["ath_uname"] = "jbloggs" form["ath_passwd"] = "foobar" - self.assert_(form.click_pairs() == + self.assertTrue(form.click_pairs() == [("ath_uname", "jbloggs"), ("ath_passwd", "foobar")]) @@ -2458,7 +2458,7 @@ file = open("./testdata/SearchType.html", "r") forms = ClientForm.ParseFile(file, self.base_uri, backwards_compat=False) - self.assert_(len(forms) == 1) + self.assertTrue(len(forms) == 1) form = forms[0] keys = ["SID", "SESSION_DIR", "Full Search", "Easy Search", @@ -2469,11 +2469,11 @@ "hidden", "hidden"] for i in range(len(keys)): key = keys[i] - self.assert_(form.find_control(key).value == values[i]) - self.assert_(form.find_control(key).type == types[i]) + self.assertTrue(form.find_control(key).value == values[i]) + self.assertTrue(form.find_control(key).type == types[i]) pairs = form.click_pairs("Full Search") - self.assert_(pairs == [ + self.assertTrue(pairs == [ ("SID", "PMrU0IJYy4MAAELSXic_E2011300_PMrU0IJYy4MAAELSXic-0"), ("SESSION_DIR", ""), ("Full Search.x", "1"), ("Full Search.y", "1"), ("Form", "Welcome"), ("JavaScript", "No")]) @@ -2485,7 +2485,7 @@ file = open("./testdata/GeneralSearch.html", "r") forms = ClientForm.ParseFile(file, self.base_uri, backwards_compat=False) - self.assert_(len(forms) == 1) + self.assertTrue(len(forms) == 1) form = forms[0] keys = ["SID", "SESSION_DIR", @@ -2515,34 +2515,34 @@ self.assertEqual(fc(name, nr=0).value, values[i]) self.assertEqual(fc(name, nr=0).type, type) self.assertEqual(fc(name, type, nr=0).name, name) - self.assert_(fc(type="hidden", nr=0).name == "SID") - self.assert_(fc(type="image", nr=0).name == "Home") - self.assert_(fc(nr=6).name == "Search") + self.assertTrue(fc(type="hidden", nr=0).name == "SID") + self.assertTrue(fc(type="image", nr=0).name == "Home") + self.assertTrue(fc(nr=6).name == "Search") self.assertRaises(ControlNotFoundError, fc, nr=50) self.assertRaises(ValueError, fc, nr=-1) - self.assert_(fc("Search", "image", nr=0).name == "Search") + self.assertTrue(fc("Search", "image", nr=0).name == "Search") self.assertRaises(ControlNotFoundError, fc, "Search", "hidden") s0 = fc("Search", "image", nr=0) s0b = fc("Search", "image", nr=0) s1 = fc("Search", "image", nr=1) - self.assert_(s0.name == s1.name == "Search") - self.assert_(s0 is s0b) - self.assert_(s0 is not s1) + self.assertTrue(s0.name == s1.name == "Search") + self.assertTrue(s0 is s0b) + self.assertTrue(s0 is not s1) self.assertRaises(ControlNotFoundError, fc, "Search", "image", nr=2) - self.assert_(fc(type="text", nr=2).name == "journal") - self.assert_(fc("Search", nr=0) is not fc("Search", nr=1)) + self.assertTrue(fc(type="text", nr=2).name == "journal") + self.assertTrue(fc("Search", nr=0) is not fc("Search", nr=1)) form["topic"] = "foo" - self.assert_(form["topic"] == "foo") + self.assertTrue(form["topic"] == "foo") form["author"] = "bar" form["journal"] = "" form["address"] = "baz" form["languagetype"] = ["English", "Catalan"] - self.assert_(form["languagetype"] == ["English", "Catalan"]) + self.assertTrue(form["languagetype"] == ["English", "Catalan"]) form["titleonly"] = ["on"] - self.assert_(form["titleonly"] == ["on"]) + self.assertTrue(form["titleonly"] == ["on"]) pairs = form.click_pairs("Search") - self.assert_(pairs == [ + self.assertTrue(pairs == [ ("SID", "PMrU0IJYy4MAAELSXic_E2011300_PMrU0IJYy4MAAELSXic-0"), ("SESSION_DIR", ""), ("Search.x", "1"), ("Search.y", "1"), @@ -2556,14 +2556,14 @@ hide_deprecations() pvs = form.possible_items("languagetype") - self.assert_(pvs[0] == "All languages") - self.assert_(len(pvs) == 47) + self.assertTrue(pvs[0] == "All languages") + self.assertTrue(len(pvs) == 47) self.assertRaises( ItemNotFoundError, lambda form=form: form.toggle("d'oh", "languagetype")) form.toggle("English", "languagetype") - self.assert_(form["languagetype"] == ["Catalan"]) + self.assertTrue(form["languagetype"] == ["Catalan"]) self.assertRaises(TypeError, form.toggle, ["Catalan"], "languagetype") self.assertRaises(TypeError, form.toggle, "Catalan", ["languagetype"]) @@ -2573,15 +2573,15 @@ # multiple select form["languagetype"] = [] - self.assert_(form["languagetype"] == []) + self.assertTrue(form["languagetype"] == []) form.set(True, "Catalan", "languagetype") - self.assert_(form["languagetype"] == ["Catalan"]) + self.assertTrue(form["languagetype"] == ["Catalan"]) form.set(True, "English", "languagetype") - self.assert_(form["languagetype"] == ["English", "Catalan"]) + self.assertTrue(form["languagetype"] == ["English", "Catalan"]) form.set(False, "English", "languagetype") - self.assert_(form["languagetype"] == ["Catalan"]) + self.assertTrue(form["languagetype"] == ["Catalan"]) form.set(False, "Catalan", "languagetype") - self.assert_(form["languagetype"] == []) + self.assertTrue(form["languagetype"] == []) self.assertRaises(ItemNotFoundError, form.set, True, "doh", "languagetype") self.assertRaises(ItemNotFoundError, form.set, False, "doh", "languagetype") self.assertRaises(ControlNotFoundError, form.set, True, "blah", "oops") @@ -2592,7 +2592,7 @@ def setitem(name, value, form=form): form[name] = value form["languagetype"] = ["Catalan"] - self.assert_(form["languagetype"] == ["Catalan"]) + self.assertTrue(form["languagetype"] == ["Catalan"]) self.assertRaises(ItemNotFoundError, setitem, "languagetype", ["doh"]) self.assertRaises(ControlNotFoundError, setitem, "oops", ["blah"]) @@ -2600,13 +2600,13 @@ # single select form["Sort"] = [] - self.assert_(form["Sort"] == []) + self.assertTrue(form["Sort"] == []) form.set(True, "Relevance", "Sort") - self.assert_(form["Sort"] == ["Relevance"]) + self.assertTrue(form["Sort"] == ["Relevance"]) form.set(True, "Times Cited", "Sort") - self.assert_(form["Sort"] == ["Times Cited"]) + self.assertTrue(form["Sort"] == ["Times Cited"]) form.set(False, "Times Cited", "Sort") - self.assert_(form["Sort"] == []) + self.assertTrue(form["Sort"] == []) self.assertRaises(ItemNotFoundError, form.set, True, "doh", "Sort") self.assertRaises(ItemNotFoundError, form.set, False, "doh", "Sort") self.assertRaises(ControlNotFoundError, form.set, True, "blah", "oops") @@ -2617,7 +2617,7 @@ reset_deprecations() form["Sort"] = ["Relevance"] - self.assert_(form["Sort"] == ["Relevance"]) + self.assertTrue(form["Sort"] == ["Relevance"]) self.assertRaises(ItemNotFoundError, setitem, "Sort", ["doh"]) self.assertRaises(ControlNotFoundError, setitem, "oops", ["blah"]) @@ -2928,13 +2928,13 @@ file = open("./testdata/Results.html", "r") forms = ClientForm.ParseFile(file, self.base_uri, backwards_compat=False) - self.assert_(len(forms) == 1) + self.assertTrue(len(forms) == 1) form = forms[0] hide_deprecations() pvs = form.possible_items("marked_list_candidates") reset_deprecations() - self.assert_(pvs == [ + self.assertTrue(pvs == [ "000174872000059/1", "000174858300003/2", "000174827900006/3"]) def bad_setitem(form=form): form["marked_list_candidates"] = ["blah"] @@ -2962,11 +2962,11 @@ for i in range(len(keys)): key = keys[i] control = form.find_control(key, nr=0) - self.assert_(control.value == values[i]) - self.assert_(control.type == types[i]) + self.assertTrue(control.value == values[i]) + self.assertTrue(control.type == types[i]) pairs = form.click_pairs("Add all records retrieved to list") - self.assert_(pairs == [ + self.assertTrue(pairs == [ ("Add all records retrieved to list.x", "1"), ("Add all records retrieved to list.y", "1"), ("marked_list_candidates", pvs[0])]) @@ -2975,13 +2975,13 @@ file = open("./testdata/MarkedResults.html", "r") forms = ClientForm.ParseFile(file, self.base_uri, backwards_compat=False) - self.assert_(len(forms) == 1) + self.assertTrue(len(forms) == 1) form = forms[0] pairs = form.click_pairs() # I've removed most of the INPUT elements from this page, and # corrected an HTML error - self.assert_(pairs == [ + self.assertTrue(pairs == [ ("Add marked records to list.x", "1"), ("Add marked records to list.y", "1"), ("marked_list_candidates", "000174872000059/1"), @@ -3069,12 +3069,12 @@ form = self.make_form() form.set_value(["v3"], type="select", kind="multilist") - self.assert_(form.get_value("d") == ["v3"]) + self.assertTrue(form.get_value("d") == ["v3"]) hide_deprecations() form.set_value(["l2"], type="select", kind="multilist", by_label=True) - self.assert_(form.get_value("d", by_label=True) == ["l2"]) - - self.assert_(form.get_value( + self.assertTrue(form.get_value("d", by_label=True) == ["l2"]) + + self.assertTrue(form.get_value( "b", "radio", "singlelist", None, 0, False) == []) form.set_value(["One"], "b", by_label=True) self.assertEqual( @@ -3089,14 +3089,14 @@ def test_id(self): form = self.make_form() - self.assert_(form.find_control("c").id == "cselect") - self.assert_(form.find_control("a").id == "1a") - self.assert_(form.find_control("b").id is None) - - self.assert_(form.find_control(id="cselect").id == "cselect") + self.assertTrue(form.find_control("c").id == "cselect") + self.assertTrue(form.find_control("a").id == "1a") + self.assertTrue(form.find_control("b").id is None) + + self.assertTrue(form.find_control(id="cselect").id == "cselect") self.assertRaises(ControlNotFoundError, form.find_control, id="coption1") - self.assert_(form.find_control(id="1a").id == "1a") + self.assertTrue(form.find_control(id="1a").id == "1a") self.assertRaises(ControlNotFoundError, form.find_control, id="1") def test_single(self): @@ -3109,21 +3109,21 @@ form.set_single(False, 'e', by_label=True) self.assertEqual(form.get_value("e"), []) form.toggle_single("e", "checkbox", "list", nr=0) - self.assert_("1" in form.get_value("e")) + self.assertTrue("1" in form.get_value("e")) form.set_single(False, "e", "checkbox", "list", nr=0) - self.assert_("1" not in form.get_value("e")) + self.assertTrue("1" not in form.get_value("e")) form.set_single(True, "e", "checkbox", "list", nr=0) - self.assert_("1" in form.get_value("e")) + self.assertTrue("1" in form.get_value("e")) reset_deprecations() def test_possible_items(self): form = self.make_form() hide_deprecations() - self.assert_(form.possible_items("c") == ["1", "2", "3"]) - self.assert_(form.possible_items("d", by_label=True) == + self.assertTrue(form.possible_items("c") == ["1", "2", "3"]) + self.assertTrue(form.possible_items("d", by_label=True) == ["l1", "l2", "l3"]) - self.assert_(form.possible_items("a") == ["1", "2", "3"]) + self.assertTrue(form.possible_items("a") == ["1", "2", "3"]) self.assertEqual(form.possible_items('e', by_label=True), [None]) self.assertEqual(form.possible_items('a', by_label=True), @@ -3137,10 +3137,10 @@ form.set_all_readonly(True) for c in form.controls: - self.assert_(c.readonly) + self.assertTrue(c.readonly) form.set_all_readonly(False) for c in form.controls: - self.assert_(not c.readonly) + self.assertTrue(not c.readonly) def test_clear_all(self): form = self.make_form() @@ -3149,7 +3149,7 @@ form.set_all_readonly(False) form.clear_all() for c in form.controls: - self.assert_(not c.value) + self.assertTrue(not c.value) def test_clear(self): form = self.make_form() @@ -3164,21 +3164,21 @@ def test_attrs(self): form = self.make_form() - self.assert_(form.attrs["blah"] == "nonsense") - self.assert_(form.attrs["name"] == "formname") + self.assertTrue(form.attrs["blah"] == "nonsense") + self.assertTrue(form.attrs["name"] == "formname") a = form.find_control("a") self.assertRaises(AttributeError, getattr, a, 'attrs') hide_deprecations() - self.assert_(a.get_item_attrs("1")["blah"] == "spam") - self.assert_(a.get_item_attrs("2")["blah"] == "eggs") - self.assert_(not a.get_item_attrs("3").has_key("blah")) + self.assertTrue(a.get_item_attrs("1")["blah"] == "spam") + self.assertTrue(a.get_item_attrs("2")["blah"] == "eggs") + self.assertTrue("blah" not in a.get_item_attrs("3")) c = form.find_control("c") - self.assert_(c.attrs["blah"] == "foo") - self.assert_(c.get_item_attrs("1")["blah"] == "bar") - self.assert_(c.get_item_attrs("2")["blah"] == "baz") - self.assert_(not c.get_item_attrs("3").has_key("blah")) + self.assertTrue(c.attrs["blah"] == "foo") + self.assertTrue(c.get_item_attrs("1")["blah"] == "bar") + self.assertTrue(c.get_item_attrs("2")["blah"] == "baz") + self.assertTrue("blah" not in c.get_item_attrs("3")) reset_deprecations() def test_select_control_nr_and_label(self): @@ -3375,7 +3375,7 @@ bndy = choose_boundary() ii = string.find(bndy, '.') - self.assert_(ii < 0) + self.assertTrue(ii < 0) def make_form(self): html = """\ @@ -3402,7 +3402,7 @@ data_control.add_file(StringIO(data)) #print "data_control._upload_data", data_control._upload_data req = form.click() - self.assert_(startswith(get_header(req, "Content-type"), + self.assertTrue(startswith(get_header(req, "Content-type"), 'multipart/form-data; boundary=')) #print "req.get_data()\n>>%s<<" % req.get_data() @@ -3411,9 +3411,9 @@ fs = cgi.FieldStorage(StringIO(req.get_data()), CaseInsensitiveDict(header_items(req)), environ={"REQUEST_METHOD": "POST"}) - self.assert_(fs["user"].value == "john") - self.assert_(fs["data"].value == data) - self.assertEquals(fs["data"].filename, "") + self.assertTrue(fs["user"].value == "john") + self.assertTrue(fs["data"].value == data) + self.assertEqual(fs["data"].filename, "") def test_file_request_with_filename(self): import cgi @@ -3425,16 +3425,16 @@ data = "blah\nbaz\n" data_control.add_file(StringIO(data), filename="afilename") req = form.click() - self.assert_(startswith(get_header(req, "Content-type"), + self.assertTrue(startswith(get_header(req, "Content-type"), 'multipart/form-data; boundary=')) # ...and check the resulting request is understood by cgi module fs = cgi.FieldStorage(StringIO(req.get_data()), CaseInsensitiveDict(header_items(req)), environ={"REQUEST_METHOD": "POST"}) - self.assert_(fs["user"].value == "john") - self.assert_(fs["data"].value == data) - self.assert_(fs["data"].filename == "afilename") + self.assertTrue(fs["user"].value == "john") + self.assertTrue(fs["data"].value == data) + self.assertTrue(fs["data"].filename == "afilename") def test_multipart_file_request(self): import cgi @@ -3450,7 +3450,7 @@ yet_more_data = "rheum\nrhaponicum\n" data_control.add_file(StringIO(yet_more_data), filename="filenamec") req = form.click() - self.assert_(startswith(get_header(req, "Content-type"), + self.assertTrue(startswith(get_header(req, "Content-type"), 'multipart/form-data; boundary=')) #print "req.get_data()\n>>%s<<" % req.get_data() @@ -3459,7 +3459,7 @@ fs = cgi.FieldStorage(StringIO(req.get_data()), CaseInsensitiveDict(header_items(req)), environ={"REQUEST_METHOD": "POST"}) - self.assert_(fs["user"].value == "john") + self.assertTrue(fs["user"].value == "john") fss = fs["data"][None] filenames = "filenamea", "", "filenamec" @@ -3468,13 +3468,13 @@ fs = fss[i] filename = filenames[i] data = datas[i] - self.assert_(fs.filename == filename) - self.assert_(fs.value == data) + self.assertTrue(fs.filename == filename) + self.assertTrue(fs.value == data) def test_upload_data(self): form = self.make_form() data = form.click().get_data() - self.assert_(startswith(data, "--")) + self.assertTrue(startswith(data, "--")) def test_empty_upload(self): # no controls except for INPUT/SUBMIT @@ -3485,11 +3485,11 @@ form = forms[0] data = form.click().get_data() lines = string.split(data, "\r\n") - self.assert_(startswith(lines[0], "--")) - self.assert_(lines[1] == + self.assertTrue(startswith(lines[0], "--")) + self.assertTrue(lines[1] == 'Content-Disposition: form-data; name="submit"') - self.assert_(lines[2] == lines[3] == "") - self.assert_(startswith(lines[4], "--")) + self.assertTrue(lines[2] == lines[3] == "") + self.assertTrue(startswith(lines[4], "--")) def test_no_files(self): # no files uploaded @@ -3500,7 +3500,7 @@ """), ".") form = forms[1] data = form.click().get_data() - self.assertEquals(data, """\ + self.assertEqRefactoringTool: Refactored ./test.py RefactoringTool: Refactored ./setup.py RefactoringTool: Refactored ./ez_setup.py ual(data, """\ --123\r Content-Disposition: form-data; name="spam"; filename=""\r Content-Type: application/octet-stream\r --- ./test.py (original) +++ ./test.py (refactored) @@ -18,7 +18,7 @@ else: warnings.filterwarnings( action="ignore", message="import \* only allowed at module level") - execfile(os.path.join(test_dir, "test_clientform.py")) + exec(compile(open(os.path.join(test_dir, "test_clientform.py"), "rb").read(), os.path.join(test_dir, "test_clientform.py"), 'exec')) if __name__ == "__main__": --- ./setup.py (original) +++ ./setup.py (refactored) @@ -76,7 +76,7 @@ if sys.version_info < (2, 1): ignore_keys.append("platforms") for key in ignore_keys: - if kwargs.has_key(key): + if key in kwargs: del kwargs[key] # Only want packages keyword if this is a package, # only want py_modules keyword if this is a single-file module, @@ -85,7 +85,7 @@ del kwargs["packages"] else: del kwargs["py_modules"] - apply(_setup, (), kwargs) + _setup(*(), **kwargs) else: import ez_setup ez_setup.use_setuptools() --- ./ez_setup.py (original) +++ ./ez_setup.py (refactored) @@ -42,10 +42,10 @@ from md5 import md5 digest = md5(data).hexdigest() if digest != md5_data[egg_name]: - print >>sys.stderr, ( + print(( "md5 validation of %s failed! (Possible download problem?)" % egg_name - ) + ), file=sys.stderr) sys.exit(2) return data @@ -68,10 +68,10 @@ try: import setuptools if setuptools.__version__ == '0.0.1': - print >>sys.stderr, ( + print(( "You have an obsolete version of setuptools installed. Please\n" "remove it from your system entirely before rerunning this script." - ) + ), file=sys.stderr) sys.exit(2) except ImportError: egg = download_setuptools(version, download_base, to_dir, download_delay) @@ -82,13 +82,13 @@ try: pkg_resources.require("setuptools>="+version) - except pkg_resources.VersionConflict, e: + except pkg_resources.VersionConflict as e: # XXX could we install in a subprocess here? - print >>sys.stderr, ( + print(( "The required version of setuptools (>=%s) is not available, and\n" "can't be installed while this script is running. Please install\n" " a more recent version first.\n\n(Currently using %r)" - ) % (version, e.args[0]) + ) % (version, e.args[0]), file=sys.stderr) sys.exit(2) def download_setuptools( @@ -102,7 +102,7 @@ with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. """ - import urllib2, shutil + import urllib.request, urllib.error, urllib.parse, shutil egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3]) url = download_base + egg_name saveto = os.path.join(to_dir, egg_name) @@ -128,7 +128,7 @@ version, download_base, delay, url ); from time import sleep; sleep(delay) log.warn("Downloading %s", url) - src = urllib2.urlopen(url) + src = urllib.request.urlopen(url) # Read/write all in one block, so we don't create a corrupt file # if the download is interrupted. data = _validate_md5(egg_name, src.read()) @@ -174,8 +174,8 @@ from setuptools.command.easy_install import main main(argv) else: - print "Setuptools version",version,"or greater has been installed." - print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)' + print("Setuptools version",version,"or greater has been installed.") + print('(Run "ez_setup.py -U setuptools" toRefactoringTool: Refactored ./examples/simple.py RefactoringTool: Refactored ./examples/example.py reinstall or upgrade.)') @@ -191,7 +191,7 @@ md5_data[base] = md5(f.read()).hexdigest() f.close() - data = [" %r: %r,\n" % it for it in md5_data.items()] + data = [" %r: %r,\n" % it for it in list(md5_data.items())] data.sort() repl = "".join(data) @@ -201,7 +201,7 @@ match = re.search("\nmd5_data = {\n([^}]+)}", src) if not match: - print >>sys.stderr, "Internal error!" + print("Internal error!", file=sys.stderr) sys.exit(2) src = src[:match.start(1)] + repl + src[match.end(1):] --- ./examples/simple.py (original) +++ ./examples/simple.py (refactored) @@ -1,14 +1,14 @@ #!/usr/bin/env python -from urllib2 import urlopen +from urllib.request import urlopen from ClientForm import ParseResponse response = urlopen("http://wwwsearch.sourceforge.net/ClientForm/example.html") forms = ParseResponse(response, backwards_compat=False) form = forms[0] -print form +print(form) form["comments"] = "Thanks, Gisle" # form.click() returns a urllib2.Request object # (see HTMLForm.click.__doc__ if you don't have urllib2) -print urlopen(form.click()).read() +print(urlopen(form.click()).read()) --- ./examples/example.py (original) +++ ./examples/example.py (refactored) @@ -1,10 +1,10 @@ #!/usr/bin/env python import ClientForm -import urllib2 -request = urllib2.Request( +import urllib.request, urllib.error, urllib.parse +request = urllib.request.Request( "http://wwwsearch.sourceforge.net/ClientForm/example.html") -response = urllib2.urlopen(request) +response = urllib.request.urlopen(request) forms = ClientForm.ParseResponse(response, backwards_compat=False) response.close() ## f = open("example.html") @@ -12,7 +12,7 @@ ## backwards_compat=False) ## f.close() form = forms[0] -print form # very useful! +print(form) # very useful! # A 'control' is a graphical HTML form widget: a text entry box, a # dropdown 'select' list, a checkbox, etc. @@ -39,9 +39,9 @@ # All Controls may be disabled (equivalent of greyed-out in browser)... control = form.find_control("comments") -print control.disabled +print(control.disabled) # ...or readonly -print control.readonly +print(control.readonly) # readonly and disabled attributes can be assigned to control.disabled = False # convenience method, used here to make all controls writable (unless @@ -75,11 +75,11 @@ # You can get the Control instances from inside the form... control = form.find_control("cheeses", type="select") -print control.name, control.value, control.type +print(control.name, control.value, control.type) control.value = ["mascarpone", "curd"] # ...and the Item instances from inside the Control item = control.get("curd") -print item.name, item.selected, item.id, item.attrs +print(item.name, item.selected, item.id, item.attrs) item.selected = False # Controls may be referred to by label: @@ -115,7 +115,7 @@ # Control.items is a list of all Item instances in the control for item in form.find_control("cheeses").items: - print item.name + print(item.name) # To remove items from a list control, remove it from .items: cheeses = form.find_control("cheeses") @@ -140,12 +140,12 @@ # Which items are present, selected, and successful? # is the "parmesan" item of the "cheeses" control successful (selected # and not disabled)? -print "parmesan" in form["cheeses"] +print("parmesan" in form["cheeses"]) # is the "parmesan" item of the "cheeses" control selected? -print "parmesan" in [ - item.name for item in form.find_control("cheeses").items if item.selected] +print("parmesan" in [ + item.name for item in form.find_control("cheeses").items if item.selected]) # does cheeses control have a "caerphilly" item? -print "caerphilly" in [item.name for item in form.find_control("cheeses").items] +print("caerphilly" in [item.name for item in form.find_control("cheeses").items]) # Sometimes one wants to set or clear individual items in a list, rather # than setting the whole .value: @@ -167,18 +167,18 @@ # Items RefactoringTool: Refactored ./ClientForm.py may be disabled (selecting or de-selecting a disabled item is # not allowed): control = form.find_control("cheeses") -print control.get("emmenthal").disabled +print(control.get("emmenthal").disabled) control.get("emmenthal").disabled = True # enable all items in control control.set_all_items_disabled(False) request2 = form.click() # urllib2.Request object try: - response2 = urllib2.urlopen(request2) -except urllib2.HTTPError, response2: + response2 = urllib.request.urlopen(request2) +except urllib.error.HTTPError as response2: pass -print response2.geturl() -print response2.info() # headers -print response2.read() # body +print(response2.geturl()) +print(response2.info()) # headers +print(response2.read()) # body response2.close() --- ./ClientForm.py (original) +++ ./ClientForm.py (refactored) @@ -102,9 +102,9 @@ handler.setLevel(logging.DEBUG) _logger.addHandler(handler) -import sys, urllib, urllib2, types, copy, urlparse, \ - htmlentitydefs, re, random -from cStringIO import StringIO +import sys, urllib.request, urllib.parse, urllib.error, urllib.request, urllib.error, urllib.parse, types, copy, urllib.parse, \ + html.entities, re, random +from io import StringIO import sgmllib # monkeypatch to fix http://www.python.org/sf/803422 :-( @@ -113,7 +113,7 @@ # HTMLParser.HTMLParser is recent, so live without it if it's not available # (also, sgmllib.SGMLParser is much more tolerant of bad HTML) try: - import HTMLParser + import html.parser except ImportError: HAVE_MODULE_HTMLPARSER = oFalse else: @@ -160,7 +160,7 @@ if hasattr(query,"items"): # mapping objects - query = query.items() + query = list(query.items()) else: # it's a bother at times that strings and string-like objects are # sequences... @@ -168,7 +168,7 @@ # non-sequence items should not work with len() x = len(query) # non-empty strings will fail this - if len(query) and type(query[0]) != types.TupleType: + if len(query) and type(query[0]) != tuple: raise TypeError() # zero-length sequences of all types will get here and succeed, # but that's a minor nit - since the original implementation @@ -183,20 +183,20 @@ if not doseq: # preserve old behavior for k, v in query: - k = urllib.quote_plus(str(k)) - v = urllib.quote_plus(str(v)) + k = urllib.parse.quote_plus(str(k)) + v = urllib.parse.quote_plus(str(v)) l.append(k + '=' + v) else: for k, v in query: - k = urllib.quote_plus(str(k)) - if type(v) == types.StringType: - v = urllib.quote_plus(v) + k = urllib.parse.quote_plus(str(k)) + if type(v) == bytes: + v = urllib.parse.quote_plus(v) l.append(k + '=' + v) - elif type(v) == types.UnicodeType: + elif type(v) == str: # is there a reasonable way to convert to ASCII? # encode generates a string, but "replace" or "ignore" # lose information and "strict" can raise UnicodeError - v = urllib.quote_plus(v.encode("ASCII","replace")) + v = urllib.parse.quote_plus(v.encode("ASCII","replace")) l.append(k + '=' + v) else: try: @@ -204,12 +204,12 @@ x = len(v) except TypeError: # not a sequence - v = urllib.quote_plus(str(v)) + v = urllib.parse.quote_plus(str(v)) l.append(k + '=' + v) else: # loop over the sequence for elt in v: - l.append(k + '=' + urllib.quote_plus(str(elt))) + l.append(k + '=' + urllib.parse.quote_plus(str(elt))) return '&'.join(l) def unescape(data, entities, encoding=DEFAULT_ENCODING): @@ -239,7 +239,7 @@ name, base = data, 10 if name.startswith("x"): name, base= name[1:], 16 - uc = unichr(int(name, base)) + uc = chr(int(name, base)) if encoding is None: return uc else: @@ -250,21 +250,21 @@ return repl def get_entitydefs(): - import htmlentitydefs + import html.entities from codecs import latin_1_decode entitydefs = {} try: - htmlentitydefs.name2codepoint + html.entities.name2codepoint except AttributeError: entitydefs = {} - for name, char in htmlentitydefs.entitydefs.items(): + for name, char in list(html.entities.entitydefs.items()): uc = latin_1_decode(char)[0] if uc.startswith("&#") and uc.endswith(";"): uc = unescape_charref(uc[2:-1], None) entitydefs["&%s;" % name] = uc else: - for name, codepoint in htmlentitydefs.name2codepoint.items(): - entitydefs["&%s;" % name] = unichr(codepoint) + for name, codepoint in list(html.entities.name2codepoint.items()): + entitydefs["&%s;" % name] = chr(codepoint) return entitydefs @@ -286,7 +286,7 @@ def choose_boundary(): """Return a string usable as a multipart boundary.""" # follow IE and firefox - nonce = "".join([str(random.randint(0, sys.maxint-1)) for i in 0,1,2]) + nonce = "".join([str(random.randint(0, sys.maxsize-1)) for i in (0,1,2)]) return "-"*27 + nonce # This cut-n-pasted MimeWriter from standard library is here so can add @@ -448,7 +448,7 @@ if HAVE_MODULE_HTMLPARSER: SGMLLIB_PARSEERROR = sgmllib.SGMLParseError class ParseError(sgmllib.SGMLParseError, - HTMLParser.HTMLParseError, + html.parser.HTMLParseError, ): pass else: @@ -586,8 +586,8 @@ self._option = {} self._option.update(d) - if (self._optgroup and self._optgroup.has_key("disabled") and - not self._option.has_key("disabled")): + if (self._optgroup and "disabled" in self._optgroup and + "disabled" not in self._option): self._option["disabled"] = None def _end_option(self): @@ -597,9 +597,9 @@ contents = self._option.get("contents", "").strip() self._option["contents"] = contents - if not self._option.has_key("value"): + if "value" not in self._option: self._option["value"] = contents - if not self._option.has_key("label"): + if "label" not in self._option: self._option["label"] = contents # stuff dict of SELECT HTML attrs into a special private key # (gets deleted again later) @@ -687,7 +687,7 @@ else: return - if data and not map.has_key(key): + if data and key not in map: # according to # http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.1 line break # immediately after start tags or immediately before end tags must @@ -759,7 +759,7 @@ def unescape_attrs(self, attrs): #debug("%s", attrs) escaped_attrs = {} - for key, val in attrs.items(): + for key, val in list(attrs.items()): try: val.items except AttributeError: @@ -778,17 +778,17 @@ def __init__(self, entitydefs=None, encoding=DEFAULT_ENCODING): raise ValueError("HTMLParser could not be imported") else: - class XHTMLCompatibleFormParser(_AbstractFormParser, HTMLParser.HTMLParser): + class XHTMLCompatibleFormParser(_AbstractFormParser, html.parser.HTMLParser): """Good for XHTML, bad for tolerance of incorrect HTML.""" # thanks to Michael Howitz for this! def __init__(self, entitydefs=None, encoding=DEFAULT_ENCODING): - HTMLParser.HTMLParser.__init__(self) + html.parser.HTMLParser.__init__(self) _AbstractFormParser.__init__(self, entitydefs, encoding) def feed(self, data): try: - HTMLParser.HTMLParser.feed(self, data) - except HTMLParser.HTMLParseError, exc: + html.parser.HTMLParser.feed(self, data) + except html.parser.HTMLParseError as exc: raise ParseError(exc) def start_option(self, attrs): @@ -829,7 +829,7 @@ return attrs # ditto def close(self): - HTMLParser.HTMLParser.close(self) + html.parser.HTMLParser.close(self) self.end_body() @@ -866,7 +866,7 @@ def feed(self, data): try: sgmllib.SGMLParser.feed(self, data) - except SGMLLIB_PARSEERROR, exc: + except SGMLLIB_PARSEERROR as exc: raise ParseError(exc) def close(self): @@ -892,7 +892,7 @@ def feed(self, data): try: self.bs_base_class.feed(self, data) - except SGMLLIB_PARSEERROR, exc: + except SGMLLIB_PARSEERROR as exc: raise ParseError(exc) def close(self): self.bs_base_class.close(self) @@ -934,14 +934,14 @@ def ParseResponseEx(response, select_default=oFalse, form_parser_class=FormParser, - request_class=urllib2.Request, + request_class=urllib.request.Request, entitydefs=None, encoding=DEFAULT_ENCODING, # private - _urljoin=urlparse.urljoin, - _urlparse=urlparse.urlparse, - _urlunparse=urlparse.urlunparse, + _urljoin=urllib.parse.urljoin, + _urlparse=urllib.parse.urlparse, + _urlunparse=urllib.parse.urlunparse, ): """Identical to ParseResponse, except that: @@ -968,14 +968,14 @@ def ParseFileEx(file, base_uri, select_default=oFalse, form_parser_class=FormParser, - request_class=urllib2.Request, + request_class=urllib.request.Request, entitydefs=None, encoding=DEFAULT_ENCODING, # private - _urljoin=urlparse.urljoin, - _urlparse=urlparse.urlparse, - _urlunparse=urlparse.urlunparse, + _urljoin=urllib.parse.urljoin, + _urlparse=urllib.parse.urlparse, + _urlunparse=urllib.parse.urlunparse, ): """Identical to ParseFile, except that: @@ -1081,13 +1081,13 @@ select_default=oFalse, ignore_errors=oFalse, form_parser_class=FormParser, - request_class=urllib2.Request, + request_class=urllib.request.Request, entitydefs=None, backwards_compat=oTrue, encoding=DEFAULT_ENCODING, - _urljoin=urlparse.urljoin, - _urlparse=urlparse.urlparse, - _urlunparse=urlparse.urlunparse, + _urljoin=urllib.parse.urljoin, + _urlparse=urllib.parse.urlparse, + _urlunparse=urllib.parse.urlunparse, ): if backwards_compat: deprecation("operating in backwards-compatibility mode", 1) @@ -1096,7 +1096,7 @@ data = file.read(CHUNK) try: fp.feed(data) - except ParseError, e: + except ParseError as e: e.base_uri = base_uri raise if len(data) != CHUNK: break @@ -1310,16 +1310,16 @@ self.__dict__["type"] = type.lower() self.__dict__["name"] = name self._value = attrs.get("value") - self.disabled = attrs.has_key("disabled") - self.readonly = attrs.has_key("readonly") + self.disabled = "disabled" in attrs + self.readonly = "readonly" in attrs self.id = attrs.get("id") self.attrs = attrs.copy() self._clicked = oFalse - self._urlparse = urlparse.urlparse - self._urlunparse = urlparse.urlunparse + self._urlparse = urllib.parse.urlparse + self._urlunparse = urllib.parse.urlunparse def __getattr__(self, name): if name == "value": @@ -1531,7 +1531,7 @@ def _totally_ordered_pairs(self): return [] - def _click(self, form, coord, return_type, request_class=urllib2.Request): + def _click(self, form, coord, return_type, request_class=urllib.request.Request): # Relative URL for ISINDEX submission: instead of "foo=bar+baz", # want "bar+baz". # This doesn't seem to be specified in HTML 4.01 spec. (ISINDEX is @@ -1539,7 +1539,7 @@ # Submission of ISINDEX is explained in the HTML 3.2 spec, though. parts = self._urlparse(form.action) rest, (query, frag) = parts[:-2], parts[-2:] - parts = rest + (urllib.quote_plus(self.value), None) + parts = rest + (urllib.parse.quote_plus(self.value), None) url = self._urlunparse(parts) req_data = url, None, [] @@ -1611,7 +1611,7 @@ "_labels": label and [label] or [], "attrs": attrs, "_control": control, - "disabled": attrs.has_key("disabled"), + "disabled": "disabled" in attrs, "_selected": oFalse, "id": attrs.get("id"), "_index": index, @@ -1665,7 +1665,7 @@ def __repr__(self): # XXX appending the attrs without distinguishing them from name and id # is silly - attrs = [("name", self.name), ("id", self.id)]+self.attrs.items() + attrs = [("name", self.name), ("id", self.id)]+list(self.attrs.items()) return "<%s %s>" % ( self.__class__.__name__, " ".join(["%s=%r" % (k, v) for k, v in attrs]) @@ -1673,7 +1673,7 @@ def disambiguate(items, nr, **kwds): msgs = [] - for key, value in kwds.items(): + for key, value in list(kwds.items()): msgs.append("%s=%r" % (key, value)) msg = " ".join(msgs) if not items: @@ -2143,11 +2143,11 @@ item.selected and (not item.disabled or compat)] names = {} for nn in value: - if nn in names.keys(): + if nn in list(names.keys()): names[nn] += 1 else: names[nn] = 1 - for name, count in names.items(): + for name, count in list(names.items()): on, off = self._get_items(name, count) for i in range(count): if on: @@ -2279,7 +2279,7 @@ called_as_base_class=oTrue, index=index) self.__dict__["multiple"] = oFalse o = Item(self, attrs, index) - o.__dict__["_selected"] = attrs.has_key("checked") + o.__dict__["_selected"] = "checked" in attrs def fixup(self): ListControl.fixup(self) @@ -2312,7 +2312,7 @@ called_as_base_class=oTrue, index=index) self.__dict__["multiple"] = oTrue o = Item(self, attrs, index) - o.__dict__["_selected"] = attrs.has_key("checked") + o.__dict__["_selected"] = "checked" in attrs def get_labels(self): return [] @@ -2380,7 +2380,7 @@ self.attrs = attrs["__select"].copy() self.__dict__["_label"] = _get_label(self.attrs) self.__dict__["id"] = self.attrs.get("id") - self.__dict__["multiple"] = self.attrs.has_key("multiple") + self.__dict__["multiple"] = "multiple" in self.attrs # the majority of the contents, label, and value dance already happened contents = attrs.get("contents") attrs = attrs.copy() @@ -2388,12 +2388,12 @@ ListControl.__init__(self, type, name, self.attrs, select_default, called_as_base_class=oTrue, index=index) - self.disabled = self.attrs.has_key("disabled") - self.readonly = self.attrs.has_key("readonly") - if attrs.has_key("value"): + self.disabled = "disabled" iRefactoringTool: Files that were modified: RefactoringTool: ./test/test_clientform.py RefactoringTool: ./test.py RefactoringTool: ./setup.py RefactoringTool: ./ez_setup.py RefactoringTool: ./examples/simple.py RefactoringTool: ./examples/example.py RefactoringTool: ./ClientForm.py n self.attrs + self.readonly = "readonly" in self.attrs + if "value" in attrs: # otherwise it is a marker 'select started' token o = Item(self, attrs, index) - o.__dict__["_selected"] = attrs.has_key("selected") + o.__dict__["_selected"] = "selected" in attrs # add 'label' label and contents label, if different. If both are # provided, the 'label' label is used for display in HTML # 4.0-compliant browsers (and any lower spec? not sure) while the @@ -2458,7 +2458,7 @@ def is_of_kind(self, kind): return kind == "clickable" - def _click(self, form, coord, return_type, request_class=urllib2.Request): + def _click(self, form, coord, return_type, request_class=urllib.request.Request): self._clicked = coord r = form._switch_click(return_type, request_class) self._clicked = oFalse @@ -2754,7 +2754,7 @@ def __init__(self, action, method="GET", enctype="application/x-www-form-urlencoded", name=None, attrs=None, - request_class=urllib2.Request, + request_class=urllib.request.Request, forms=None, labels=None, id_to_labels=None, backwards_compat=True): """ @@ -2786,8 +2786,8 @@ self.backwards_compat = backwards_compat # note __setattr__ - self._urlunparse = urlparse.urlunparse - self._urlparse = urlparse.urlparse + self._urlunparse = urllib.parse.urlunparse + self._urlparse = urllib.parse.urlparse def __getattr__(self, name): if name == "backwards_compat": @@ -2893,7 +2893,7 @@ control = self.find_control(name) try: control.value = value - except AttributeError, e: + except AttributeError as e: raise ValueError(str(e)) def get_value(self, @@ -3085,7 +3085,7 @@ # Form submission methods, applying only to clickable controls. def click(self, name=None, type=None, id=None, nr=0, coord=(1,1), - request_class=urllib2.Request, + request_class=urllib.request.Request, label=None): """Return request that would result from clicking on a control. @@ -3114,7 +3114,7 @@ def click_request_data(self, name=None, type=None, id=None, nr=0, coord=(1,1), - request_class=urllib2.Request, + request_class=urllib.request.Request, label=None): """As for click method, but return a tuple (url, data, headers). @@ -3305,7 +3305,7 @@ assert oFalse def _click(self, name, type, id, label, nr, coord, return_type, - request_class=urllib2.Request): + request_class=urllib.request.Request): try: control = self._find_control( name, type, "clickable", id, label, None, nr) @@ -3377,7 +3377,7 @@ else: raise ValueError("Unknown method '%s'" % method) - def _switch_click(self, return_type, request_class=urllib2.Request): + def _switch_click(self, return_type, request_class=urllib.request.Request): # This is called by HTMLForm and clickable Controls to hide switching # on return_type. if return_type == "pairs": + CFLAGS='-pipe -frecord-gcc-switches -Wall -g -O2 -flto=auto -march=i586 -mtune=generic' + export CFLAGS + CXXFLAGS='-pipe -frecord-gcc-switches -Wall -g -O2 -flto=auto -march=i586 -mtune=generic' + export CXXFLAGS + FFLAGS='-pipe -frecord-gcc-switches -Wall -g -O2 -flto=auto -march=i586 -mtune=generic' + export FFLAGS + /usr/bin/python3 setup.py build running build running build_py creating build creating build/lib copying ClientForm.py -> build/lib + exit 0 Executing(%install): /bin/sh -e /usr/src/tmp/rpm-tmp.98843 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + /bin/chmod -Rf u+rwX -- /usr/src/tmp/python3-module-ClientForm-buildroot + : + /bin/rm -rf -- /usr/src/tmp/python3-module-ClientForm-buildroot + PATH=/usr/libexec/rpm-build:/usr/src/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games + cd ClientForm-0.2.10 + CFLAGS='-pipe -frecord-gcc-switches -Wall -g -O2 -flto=auto -march=i586 -mtune=generic' + export CFLAGS + CXXFLAGS='-pipe -frecord-gcc-switches -Wall -g -O2 -flto=auto -march=i586 -mtune=generic' + export CXXFLAGS + FFLAGS='-pipe -frecord-gcc-switches -Wall -g -O2 -flto=auto -march=i586 -mtune=generic' + export FFLAGS + /usr/bin/python3 setup.py install --skip-build --root=/usr/src/tmp/python3-module-ClientForm-buildroot --force running install /usr/lib/python3/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running install_lib creating /usr/src/tmp/python3-module-ClientForm-buildroot creating /usr/src/tmp/python3-module-ClientForm-buildroot/usr creating /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib creating /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3 creating /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages copying build/lib/ClientForm.py -> /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages byte-compiling /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py to ClientForm.cpython-39.pyc running install_egg_info running egg_info writing ClientForm.egg-info/PKG-INFO writing dependency_links to ClientForm.egg-info/dependency_links.txt writing top-level names to ClientForm.egg-info/top_level.txt reading manifest file 'ClientForm.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' adding license file 'COPYING.txt' writing manifest file 'ClientForm.egg-info/SOURCES.txt' Copying ClientForm.egg-info to /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm-0.2.10-py3.9.egg-info running install_scripts + /usr/lib/rpm/brp-alt Cleaning files in /usr/src/tmp/python3-module-ClientForm-buildroot (auto) Verifying and fixing files in /usr/src/tmp/python3-module-ClientForm-buildroot (binconfig,pkgconfig,libtool,desktop,gnuconfig) Checking contents of files in /usr/src/tmp/python3-module-ClientForm-buildroot/ (default) Compressing files in /usr/src/tmp/python3-module-ClientForm-buildroot (auto) Adjusting library links in /usr/src/tmp/python3-module-ClientForm-buildroot ./usr/lib: (from :0) Verifying ELF objects in /usr/src/tmp/python3-module-ClientForm-buildroot (arch=normal,fhs=normal,lfs=relaxed,lint=relaxed,rpath=normal,stack=normal,textrel=normal,unresolved=normal) Bytecompiling python3 modules in /usr/src/tmp/python3-module-ClientForm-buildroot using /usr/bin/python3 unlink /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages/__pycache__/ClientForm.cpython-39.pyc compile /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py Bytecompiling python3 modules with optimization in /usr/src/tmp/python3-module-ClientForm-buildroot using /usr/bin/python3 -O compile /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py Bytecompiling python3 modules with optimization-2 in /usr/src/tmp/python3-module-ClientForm-buildroot using /usr/bin/python3 -OO compile /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py Hardlinking identical .pyc and .opt-?.pyc files Processing files: python3-module-ClientForm-0.2.10-alt5 Executing(%doc): /bin/sh -e /usr/src/tmp/rpm-tmp.98843 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd ClientForm-0.2.10 + DOCDIR=/usr/src/tmp/python3-module-ClientForm-buildroot/usr/share/doc/python3-module-ClientForm-0.2.10 + export DOCDIR + rm -rf /usr/src/tmp/python3-module-ClientForm-buildroot/usr/share/doc/python3-module-ClientForm-0.2.10 + /bin/mkdir -p /usr/src/tmp/python3-module-ClientForm-buildroot/usr/share/doc/python3-module-ClientForm-0.2.10 + cp -prL ChangeLog.txt COPYING.txt COPYRIGHT.txt GeneralFAQ.html README.txt /usr/src/tmp/python3-module-ClientForm-buildroot/usr/share/doc/python3-module-ClientForm-0.2.10 + chmod -R go-w /usr/src/tmp/python3-module-ClientForm-buildroot/usr/share/doc/python3-module-ClientForm-0.2.10 + chmod -R a+rX /usr/src/tmp/python3-module-ClientForm-buildroot/usr/share/doc/python3-module-ClientForm-0.2.10 + exit 0 Finding Provides (using /usr/lib/rpm/find-provides) Executing: /bin/sh -e /usr/src/tmp/rpm-tmp.0csLHU find-provides: running scripts (alternatives,debuginfo,lib,pam,perl,pkgconfig,python,python3,shell) Finding Requires (using /usr/lib/rpm/find-requires) Executing: /bin/sh -e /usr/src/tmp/rpm-tmp.KgGY4X find-requires: running scripts (cpp,debuginfo,files,lib,pam,perl,pkgconfig,pkgconfiglib,python,python3,rpmlib,shebang,shell,static,symlinks,systemd-services) /usr/lib/rpm/python3.req.py:6: DeprecationWarning: The parser module is deprecated and will be removed in future versions of Python import parser, symbol, token, types /usr/lib/rpm/python3.req.py:6: DeprecationWarning: The symbol module is deprecated and will be removed in future versions of Python import parser, symbol, token, types /usr/lib/rpm/python3.req.py: /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py: line=79 IGNORE (for REQ=slight and deep=8) module=logging /usr/lib/rpm/python3.req.py: /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py: line=80 IGNORE (for REQ=slight and deep=8) module=inspect python3.req: /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py: skipping sys /usr/lib/rpm/python3.req.py: /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py: line=116 IGNORE (for REQ=slight and deep=8) module=html.parser /usr/lib/rpm/python3.req.py: /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py: line=123 IGNORE (for REQ=slight and deep=8) module=warnings /usr/lib/rpm/python3.req.py: /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py: line=253 IGNORE (for REQ=slight and deep=8) module=html.entities /usr/lib/rpm/python3.req.py: /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py: line=254 IGNORE (for REQ=slight and deep=8) module=codecs /usr/lib/rpm/python3.req.py: /usr/src/tmp/python3-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py: line=920 IGNORE (for REQ=slight and deep=8) module=BeautifulSoup Provides: python3(ClientForm) Requires: /usr/lib/python3/site-packages, python3(copy) < 0, python3(html.entities) < 0, python3(io) < 0, python3(random) < 0, python3(re) < 0, python3(sgmllib) < 0, python3(types) < 0, python3(urllib.error) < 0, python3(urllib.parse) < 0, python3(urllib.request) < 0 Wrote: /usr/src/RPM/RPMS/noarch/python3-module-ClientForm-0.2.10-alt5.noarch.rpm (w2.lzdio) 5.98user 0.40system 0:07.71elapsed 82%CPU (0avgtext+0avgdata 34928maxresident)k 0inputs+0outputs (0major+139122minor)pagefaults 0swaps /.out/python3-module-ClientForm-0.2.10-alt5.noarch.rpm: license not found in '/usr/share/license' directory: BSD-like 10.88user 3.57system 0:15.01elapsed 96%CPU (0avgtext+0avgdata 103676maxresident)k 0inputs+0outputs (45848major+474275minor)pagefaults 0swaps