<86>Apr 21 01:08:16 userdel[20133]: delete user 'rooter' <86>Apr 21 01:08:16 userdel[20133]: removed group 'rooter' owned by 'rooter' <86>Apr 21 01:08:16 userdel[20133]: removed shadow group 'rooter' owned by 'rooter' <86>Apr 21 01:08:16 groupadd[20179]: group added to /etc/group: name=rooter, GID=663 <86>Apr 21 01:08:16 groupadd[20179]: group added to /etc/gshadow: name=rooter <86>Apr 21 01:08:16 groupadd[20179]: new group: name=rooter, GID=663 <86>Apr 21 01:08:16 useradd[20216]: new user: name=rooter, UID=663, GID=663, home=/root, shell=/bin/bash <86>Apr 21 01:08:16 userdel[20265]: delete user 'builder' <86>Apr 21 01:08:16 userdel[20265]: removed group 'builder' owned by 'builder' <86>Apr 21 01:08:16 userdel[20265]: removed shadow group 'builder' owned by 'builder' <86>Apr 21 01:08:16 groupadd[20310]: group added to /etc/group: name=builder, GID=664 <86>Apr 21 01:08:16 groupadd[20310]: group added to /etc/gshadow: name=builder <86>Apr 21 01:08:16 groupadd[20310]: new group: name=builder, GID=664 <86>Apr 21 01:08:16 useradd[20337]: new user: name=builder, UID=664, GID=664, home=/usr/src, shell=/bin/bash <13>Apr 21 01:08:19 rpmi: libexpat-2.2.4-alt0.M80P.1 1503871120 installed <13>Apr 21 01:08:19 rpmi: libgdbm-1.8.3-alt10 1454943313 installed <13>Apr 21 01:08:19 rpmi: libtinfo-devel-5.9-alt8 1456756459 installed <13>Apr 21 01:08:19 rpmi: libncurses-devel-5.9-alt8 1456756459 installed <13>Apr 21 01:08:19 rpmi: python-modules-curses-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:19 rpmi: libverto-0.2.6-alt1_6 1455633234 installed <13>Apr 21 01:08:19 rpmi: libkeyutils-1.5.10-alt0.M80P.2 p8+216694.100.6.1 1547827915 installed <13>Apr 21 01:08:19 rpmi: libcom_err-1.42.13-alt2 1449075846 installed <13>Apr 21 01:08:19 rpmi: ca-certificates-2016.02.25-alt1 1462368370 installed <13>Apr 21 01:08:19 rpmi: libcrypto10-1.0.2n-alt0.M80P.1 1512766129 installed <13>Apr 21 01:08:19 rpmi: libssl10-1.0.2n-alt0.M80P.1 1512766129 installed <86>Apr 21 01:08:19 groupadd[31406]: group added to /etc/group: name=_keytab, GID=499 <86>Apr 21 01:08:19 groupadd[31406]: group added to /etc/gshadow: name=_keytab <86>Apr 21 01:08:19 groupadd[31406]: new group: name=_keytab, GID=499 <13>Apr 21 01:08:19 rpmi: libkrb5-1.14.6-alt1.M80P.1 1525355673 installed <13>Apr 21 01:08:20 rpmi: python3-base-3.5.4-alt2.M80P.1 1527753911 installed <13>Apr 21 01:08:20 rpmi: python-modules-compiler-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:20 rpmi: python3-module-py-1.4.34-alt0.M80P.1 1503506764 installed <13>Apr 21 01:08:20 rpmi: python-modules-email-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:20 rpmi: python3-3.5.4-alt2.M80P.1 1527753911 installed <13>Apr 21 01:08:20 rpmi: rpm-build-python3-0.1.10.10-alt1.M80P.1 1530521451 installed <13>Apr 21 01:08:20 rpmi: python-modules-unittest-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:20 rpmi: python3-module-pytest-3.2.1-alt0.M80P.1 1503499784 installed <13>Apr 21 01:08:20 rpmi: python3-module-setuptools-1:18.5-alt0.M80P.1 1497527461 installed <13>Apr 21 01:08:21 rpmi: python-modules-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:21 rpmi: python-modules-ctypes-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:21 rpmi: python-modules-encodings-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:21 rpmi: python-modules-multiprocessing-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:21 rpmi: python-modules-logging-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:21 rpmi: python-tools-2to3-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:21 rpmi: python-modules-xml-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:21 rpmi: python-modules-hotshot-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:21 rpmi: python-modules-bsddb-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:21 rpmi: python-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:21 rpmi: python-dev-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:21 rpmi: python-module-py-1.4.34-alt0.M80P.1 1503506764 installed <13>Apr 21 01:08:21 rpmi: python-modules-json-2.7.11-alt6.M80P.1 1527682470 installed <13>Apr 21 01:08:21 rpmi: python-module-pytest-3.2.1-alt0.M80P.1 1503499784 installed <13>Apr 21 01:08:21 rpmi: python-module-setuptools-1:18.5-alt0.M80P.1 1497527461 installed Installing python-module-ClientForm-0.2.10-alt4.1.1.src.rpm Building target platforms: x86_64 Building for target x86_64 Executing(%prep): /bin/sh -e /usr/src/tmp/rpm-tmp.19194 + 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 . + cp -fR . ../python3 + exit 0 Executing(%build): /bin/sh -e /usr/src/tmp/rpm-tmp.67043 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd ClientForm-0.2.10 + CFLAGS='-pipe -Wall -g -O2' + export CFLAGS + CXXFLAGS='-pipe -Wall -g -O2' + export CXXFLAGS + FFLAGS='-pipe -Wall -g -O2' + export FFLAGS + /usr/bin/python2.7 setup.py build running build running build_py creating build creating build/lib copying ClientForm.py -> build/lib + pushd ../python3 ~/RPM/BUILD/python3 ~/RPM/BUILD/ClientForm-0.2.10 + find ../python3 -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 ../python3/test/test_clientform.py --- ../python3/test/test_clientform.py (original) +++ ../python3/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, """\ + RefactoringTool: Refactored ../python3/test.py RefactoringTool: Refactored ../python3/setup.py RefactoringTool: Refactored ../python3/ez_setup.py self.assertEqual(data, """\ --123\r Content-Disposition: form-data; name="spam"; filename=""\r Content-Type: application/octet-stream\r --- ../python3/test.py (original) +++ ../python3/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")).read(), os.path.join(test_dir, "test_clientform.py"), 'exec')) if __name__ == "__main__": --- ../python3/setup.py (original) +++ ../python3/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() --- ../python3/ez_setup.py (original) +++ ../python3/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 inRefactoringTool: Refactored ../python3/examples/simple.py RefactoringTool: Refactored ../python3/examples/example.py stalled.") + print('(Run "ez_setup.py -U setuptools" to 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):] --- ../python3/examples/simple.py (original) +++ ../python3/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()) --- ../python3/examples/example.py (original) +++ ../python3/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 cleaRefactoringTool: Refactored ../python3/ClientForm.py r individual items in a list, rather # than setting the whole .value: @@ -167,18 +167,18 @@ # Items 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() --- ../python3/ClientForm.py (original) +++ ../python3/ClientForm.py (refactored) @@ -102,18 +102,19 @@ 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 +import collections # monkeypatch to fix http://www.python.org/sf/803422 :-( sgmllib.charref = re.compile("&#(x?[0-9a-fA-F]+)[^0-9a-fA-F]") # 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 +161,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 +169,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 +184,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 +205,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 +240,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 +251,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 +287,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 +449,7 @@ if HAVE_MODULE_HTMLPARSER: SGMLLIB_PARSEERROR = sgmllib.SGMLParseError class ParseError(sgmllib.SGMLParseError, - HTMLParser.HTMLParseError, + html.parser.HTMLParseError, ): pass else: @@ -586,8 +587,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 +598,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 +688,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 +760,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 +779,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 +830,7 @@ return attrs # ditto def close(self): - HTMLParser.HTMLParser.close(self) + html.parser.HTMLParser.close(self) self.end_body() @@ -866,7 +867,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 +893,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 +935,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 +969,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 +1082,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 +1097,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 +1311,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 +1532,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 +1540,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 +1612,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 +1666,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 +1674,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 +2144,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 +2280,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 +2313,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 +2381,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 +2389,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" in 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 +2459,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 +2755,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 +2787,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 +2894,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 +3086,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 +3115,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). @@ -3245,7 +3246,7 @@ raise TypeError("control id must be string-like") if (label is not None) and not isstringlike(label): raise TypeError("control label must be string-like") - if (predicate is not None) and not callable(predicate): + if (predicate is not None) and not isinstance(predicate, collections.Callable): raise TypeError("control predicate must be callable") if (nr is not None) and nr < 0: raise ValueError("control number must be a positive integer") @@ -3305,7 +3306,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 +3378,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 ControlsRefactoringTool: Files that were modified: RefactoringTool: ../python3/test/test_clientform.py RefactoringTool: ../python3/test.py RefactoringTool: ../python3/setup.py RefactoringTool: ../python3/ez_setup.py RefactoringTool: ../python3/examples/simple.py RefactoringTool: ../python3/examples/example.py RefactoringTool: ../python3/ClientForm.py to hide switching # on return_type. if return_type == "pairs": + CFLAGS='-pipe -Wall -g -O2' + export CFLAGS + CXXFLAGS='-pipe -Wall -g -O2' + export CXXFLAGS + FFLAGS='-pipe -Wall -g -O2' + export FFLAGS + python3 setup.py build running build running build_py creating build creating build/lib copying ClientForm.py -> build/lib + popd ~/RPM/BUILD/ClientForm-0.2.10 + exit 0 Executing(%install): /bin/sh -e /usr/src/tmp/rpm-tmp.28267 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + /bin/chmod -Rf u+rwX -- /usr/src/tmp/python-module-ClientForm-buildroot + : + /bin/rm -rf -- /usr/src/tmp/python-module-ClientForm-buildroot + cd ClientForm-0.2.10 + /usr/bin/python2.7 setup.py install --skip-build --root=/usr/src/tmp/python-module-ClientForm-buildroot --force running install running install_lib creating /usr/src/tmp/python-module-ClientForm-buildroot creating /usr/src/tmp/python-module-ClientForm-buildroot/usr creating /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib creating /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7 creating /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages copying build/lib/ClientForm.py -> /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages byte-compiling /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages/ClientForm.py to ClientForm.pyc running install_egg_info running egg_info writing ClientForm.egg-info/PKG-INFO writing top-level names to ClientForm.egg-info/top_level.txt writing dependency_links to ClientForm.egg-info/dependency_links.txt reading manifest file 'ClientForm.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'ClientForm.egg-info/SOURCES.txt' Copying ClientForm.egg-info to /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages/ClientForm-0.2.10-py2.7.egg-info running install_scripts + pushd ../python3 ~/RPM/BUILD/python3 ~/RPM/BUILD/ClientForm-0.2.10 + python3 setup.py install --skip-build --root=/usr/src/tmp/python-module-ClientForm-buildroot --force running install running install_lib creating /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python3 creating /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python3/site-packages copying build/lib/ClientForm.py -> /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python3/site-packages byte-compiling /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py to ClientForm.cpython-35.pyc running install_egg_info running egg_info writing ClientForm.egg-info/PKG-INFO writing top-level names to ClientForm.egg-info/top_level.txt writing dependency_links to ClientForm.egg-info/dependency_links.txt reading manifest file 'ClientForm.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'ClientForm.egg-info/SOURCES.txt' Copying ClientForm.egg-info to /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm-0.2.10-py3.5.egg-info running install_scripts + popd ~/RPM/BUILD/ClientForm-0.2.10 + /usr/lib/rpm/brp-alt Cleaning files in /usr/src/tmp/python-module-ClientForm-buildroot (auto) Verifying and fixing files in /usr/src/tmp/python-module-ClientForm-buildroot (binconfig,pkgconfig,libtool,desktop) Compressing files in /usr/src/tmp/python-module-ClientForm-buildroot (auto) Adjusting library links in /usr/src/tmp/python-module-ClientForm-buildroot ./usr/lib: Verifying ELF objects in /usr/src/tmp/python-module-ClientForm-buildroot (arch=normal,fhs=normal,lfs=relaxed,lint=relaxed,rpath=normal,stack=normal,textrel=normal,unresolved=normal) Bytecompiling python modules in /usr/src/tmp/python-module-ClientForm-buildroot using /usr/bin/python2.7 unlink /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages/ClientForm.pyc compile /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages/ClientForm.py Bytecompiling python modules with optimization in /usr/src/tmp/python-module-ClientForm-buildroot using /usr/bin/python2.7 -O compile /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages/ClientForm.py Bytecompiling python3 modules in /usr/src/tmp/python-module-ClientForm-buildroot using python3 unlink /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python3/site-packages/__pycache__/ClientForm.cpython-35.pyc compile /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py Bytecompiling python3 modules with optimization in /usr/src/tmp/python-module-ClientForm-buildroot using python3 -O compile /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py Bytecompiling python3 modules with optimization-2 in /usr/src/tmp/python-module-ClientForm-buildroot using python3 -OO compile /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py Hardlinking identical .pyc and .opt-?.pyc files Hardlinking identical .pyc and .pyo files Processing files: python-module-ClientForm-0.2.10-alt4.1.1 Executing(%doc): /bin/sh -e /usr/src/tmp/rpm-tmp.62260 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd ClientForm-0.2.10 + DOCDIR=/usr/src/tmp/python-module-ClientForm-buildroot/usr/share/doc/python-module-ClientForm-0.2.10 + export DOCDIR + rm -rf /usr/src/tmp/python-module-ClientForm-buildroot/usr/share/doc/python-module-ClientForm-0.2.10 + /bin/mkdir -p /usr/src/tmp/python-module-ClientForm-buildroot/usr/share/doc/python-module-ClientForm-0.2.10 + cp -prL ChangeLog.txt COPYING.txt COPYRIGHT.txt GeneralFAQ.html README.txt /usr/src/tmp/python-module-ClientForm-buildroot/usr/share/doc/python-module-ClientForm-0.2.10 + chmod -R go-w /usr/src/tmp/python-module-ClientForm-buildroot/usr/share/doc/python-module-ClientForm-0.2.10 + chmod -R a+rX /usr/src/tmp/python-module-ClientForm-buildroot/usr/share/doc/python-module-ClientForm-0.2.10 + exit 0 Finding Provides (using /usr/lib/rpm/find-provides) Executing: /bin/sh -e /usr/src/tmp/rpm-tmp.9wIOxS 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.AbhfHN find-requires: running scripts (cpp,debuginfo,files,lib,pam,perl,pkgconfig,pkgconfiglib,python,python3,rpmlib,shebang,shell,static,symlinks) /usr/lib/rpm/python.req.py: /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages/ClientForm.py: line=79 IGNORE (for REQ=slight and deep=8) module=logging /usr/lib/rpm/python.req.py: /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages/ClientForm.py: line=80 IGNORE (for REQ=slight and deep=8) module=inspect python.req: /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages/ClientForm.py: skipping sys /usr/lib/rpm/python.req.py: /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages/ClientForm.py: line=116 IGNORE (for REQ=slight and deep=8) module=HTMLParser /usr/lib/rpm/python.req.py: /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages/ClientForm.py: line=123 IGNORE (for REQ=slight and deep=8) module=warnings /usr/lib/rpm/python.req.py: /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages/ClientForm.py: line=253 IGNORE (for REQ=slight and deep=8) module=htmlentitydefs /usr/lib/rpm/python.req.py: /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages/ClientForm.py: line=254 IGNORE (for REQ=slight and deep=8) module=codecs /usr/lib/rpm/python.req.py: /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python2.7/site-packages/ClientForm.py: line=920 IGNORE (for REQ=slight and deep=8) module=BeautifulSoup Provides: python2.7-module-ClientForm = 0.2.10-alt4.1.1, python2.7(ClientForm) Requires: python = 2.7, /usr/lib/python2.7/site-packages, python-modules Processing files: python3-module-ClientForm-0.2.10-alt4.1.1 Executing(%doc): /bin/sh -e /usr/src/tmp/rpm-tmp.38250 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd ClientForm-0.2.10 + DOCDIR=/usr/src/tmp/python-module-ClientForm-buildroot/usr/share/doc/python3-module-ClientForm-0.2.10 + export DOCDIR + rm -rf /usr/src/tmp/python-module-ClientForm-buildroot/usr/share/doc/python3-module-ClientForm-0.2.10 + /bin/mkdir -p /usr/src/tmp/python-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/python-module-ClientForm-buildroot/usr/share/doc/python3-module-ClientForm-0.2.10 + chmod -R go-w /usr/src/tmp/python-module-ClientForm-buildroot/usr/share/doc/python3-module-ClientForm-0.2.10 + chmod -R a+rX /usr/src/tmp/python-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.tO1OpM 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.IE1OtO find-requires: running scripts (cpp,debuginfo,files,lib,pam,perl,pkgconfig,pkgconfiglib,python,python3,rpmlib,shebang,shell,static,symlinks) /usr/lib/rpm/python3.req.py: /usr/src/tmp/python-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/python-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/python-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py: skipping sys /usr/lib/rpm/python3.req.py: /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py: line=117 IGNORE (for REQ=slight and deep=8) module=html /usr/lib/rpm/python3.req.py: /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py: line=124 IGNORE (for REQ=slight and deep=8) module=warnings /usr/lib/rpm/python3.req.py: /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py: line=254 IGNORE (for REQ=slight and deep=8) module=html /usr/lib/rpm/python3.req.py: /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py: line=255 IGNORE (for REQ=slight and deep=8) module=codecs /usr/lib/rpm/python3.req.py: /usr/src/tmp/python-module-ClientForm-buildroot/usr/lib/python3/site-packages/ClientForm.py: line=921 IGNORE (for REQ=slight and deep=8) module=BeautifulSoup Provides: python3(ClientForm), python3.3(ClientForm) Requires: /usr/lib/python3/site-packages, python3(collections) < 0, python3(copy) < 0, python3(html) < 0, python3(io) < 0, python3(random) < 0, python3(re) < 0, python3(sgmllib) < 0, python3(types) < 0, python3(urllib) < 0 warning: Installed (but unpackaged) file(s) found: /usr/lib/python3/site-packages/__pycache__/ClientForm.cpython-35.opt-1.pyc /usr/lib/python3/site-packages/__pycache__/ClientForm.cpython-35.opt-2.pyc /usr/lib/python3/site-packages/__pycache__/ClientForm.cpython-35.pyc Wrote: /usr/src/RPM/RPMS/noarch/python-module-ClientForm-0.2.10-alt4.1.1.noarch.rpm Wrote: /usr/src/RPM/RPMS/noarch/python3-module-ClientForm-0.2.10-alt4.1.1.noarch.rpm 9.64user 0.89system 0:16.39elapsed 64%CPU (0avgtext+0avgdata 63524maxresident)k 0inputs+0outputs (0major+225645minor)pagefaults 0swaps 14.26user 3.98system 0:26.84elapsed 67%CPU (0avgtext+0avgdata 122124maxresident)k 0inputs+0outputs (0major+478860minor)pagefaults 0swaps --- python3-module-ClientForm-0.2.10-alt4.1.1.noarch.rpm.repo 2016-03-13 18:48:51.000000000 +0000 +++ python3-module-ClientForm-0.2.10-alt4.1.1.noarch.rpm.hasher 2019-04-21 01:08:41.095848502 +0000 @@ -1,7 +1,7 @@ -/usr/lib/python3/site-packages/ClientForm-0.2.10-py3.3.egg-info 40755 -/usr/lib/python3/site-packages/ClientForm-0.2.10-py3.3.egg-info/PKG-INFO 100644 -/usr/lib/python3/site-packages/ClientForm-0.2.10-py3.3.egg-info/SOURCES.txt 100644 -/usr/lib/python3/site-packages/ClientForm-0.2.10-py3.3.egg-info/dependency_links.txt 100644 -/usr/lib/python3/site-packages/ClientForm-0.2.10-py3.3.egg-info/top_level.txt 100644 -/usr/lib/python3/site-packages/ClientForm-0.2.10-py3.3.egg-info/zip-safe 100644 +/usr/lib/python3/site-packages/ClientForm-0.2.10-py3.5.egg-info 40755 +/usr/lib/python3/site-packages/ClientForm-0.2.10-py3.5.egg-info/PKG-INFO 100644 +/usr/lib/python3/site-packages/ClientForm-0.2.10-py3.5.egg-info/SOURCES.txt 100644 +/usr/lib/python3/site-packages/ClientForm-0.2.10-py3.5.egg-info/dependency_links.txt 100644 +/usr/lib/python3/site-packages/ClientForm-0.2.10-py3.5.egg-info/top_level.txt 100644 +/usr/lib/python3/site-packages/ClientForm-0.2.10-py3.5.egg-info/zip-safe 100644 /usr/lib/python3/site-packages/ClientForm.py 100644 @@ -14,11 +14,11 @@ Requires: /usr/lib/python3/site-packages -Requires: python3.3(collections) -Requires: python3.3(copy) -Requires: python3.3(html) -Requires: python3.3(io) -Requires: python3.3(random) -Requires: python3.3(re) -Requires: python3.3(sgmllib) -Requires: python3.3(types) -Requires: python3.3(urllib) +Requires: python3(collections) < 0 +Requires: python3(copy) < 0 +Requires: python3(html) < 0 +Requires: python3(io) < 0 +Requires: python3(random) < 0 +Requires: python3(re) < 0 +Requires: python3(sgmllib) < 0 +Requires: python3(types) < 0 +Requires: python3(urllib) < 0 Requires: rpmlib(PayloadIsLzma)