bb/toaster: Fix assertEquals deprecation warnings
PATCH 1/3 bb/toaster: Fix assertEquals deprecation warnings
Fix:
DeprecationWarning: Please use assertEqual instead
Signed-off-by Richard Purdie <[email protected]>
--- lib/bb/tests/codeparser.py | 2 +- lib/toaster/tests/browser/test_all_builds_page.py | 8 ++++---- .../tests/browser/test_builddashboard_page_artifacts.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)
lib/bb/tests/codeparser.py +1 -1
@@ -467,6 +467,6 @@ esac # self.d.setVar("oe_libinstall", "echo test") # self.d.setVar("FOO", "foo=oe_libinstall; eval $foo") # self.d.setVarFlag("FOO", "vardeps", "oe_*") - # self.assertEquals(deps, set(["oe_libinstall"])) + # self.assertEqual(deps, set(["oe_libinstall"]))
lib/toaster/tests/browser/test_all_builds_page.py +4 -4
@@ -259,25 +259,25 @@ class TestAllBuildsPage(SeleniumTestCase): element = self._get_build_time_element(build1) links = element.find_elements(By.CSS_SELECTOR, 'a') msg = 'should be a link on the build time for a successful recent build' - self.assertEquals(len(links), 1, msg) + self.assertEqual(len(links), 1, msg) # test recent builds area for failed build element = self._get_build_time_element(build2) links = element.find_elements(By.CSS_SELECTOR, 'a') msg = 'should not be a link on the build time for a failed recent build' - self.assertEquals(len(links), 0, msg) + self.assertEqual(len(links), 0, msg) # test the time column for successful build build1_row = self._get_row_for_build(build1) links = build1_row.find_elements(By.CSS_SELECTOR, 'td.time a') msg = 'should be a link on the build time for a successful build' - self.assertEquals(len(links), 1, msg) + self.assertEqual(len(links), 1, msg) # test the time column for failed build build2_row = self._get_row_for_build(build2) links = build2_row.find_elements(By.CSS_SELECTOR, 'td.time a') msg = 'should not be a link on the build time for a failed build' - self.assertEquals(len(links), 0, msg) + self.assertEqual(len(links), 0, msg) def test_builds_table_search_box(self): """ Test the search box in the builds table on the all builds page """
lib/toaster/tests/browser/test_builddashboard_page_artifacts.py +2 -2
@@ -197,12 +197,12 @@ class TestBuildDashboardPageArtifacts(SeleniumTestCase): # check package count and size, link on target name selector = '[data-value="target-package-count"]' element = self.find(selector) - self.assertEquals(element.text, '1', + self.assertEqual(element.text, '1', 'package count should be shown for image builds') selector = '[data-value="target-package-size"]' element = self.find(selector) - self.assertEquals(element.text, '1.0 KB', + self.assertEqual(element.text, '1.0 KB', 'package size should be shown for image builds') selector = '[data-link="target-packages"]'
Signature · 1 line
2.39.2
PATCH 2/3 toaster: Fix assertRegexpMatches deprecation warnings
Fix:
DeprecationWarning: Please use assertRegex instead.
Signed-off-by Richard Purdie <[email protected]>
--- .../tests/browser/test_most_recent_builds_states.py | 8 ++++---- lib/toaster/tests/browser/test_new_custom_image_page.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)
lib/toaster/tests/browser/test_most_recent_builds_states.py +4 -4
@@ -47,7 +47,7 @@ class TestMostRecentBuildsStates(SeleniumTestCase): # build queued; check shown as queued selector = base_selector + '[data-build-state="Queued"]' element = self.wait_until_visible(selector) - self.assertRegexpMatches(element.get_attribute('innerHTML'), + self.assertRegex(element.get_attribute('innerHTML'), 'Build queued', 'build should show queued status') # waiting for recipes to be parsed
@@ -97,7 +97,7 @@ class TestMostRecentBuildsStates(SeleniumTestCase): selector = base_selector + '[data-build-state="Starting"]' element = self.wait_until_visible(selector) - self.assertRegexpMatches(element.get_attribute('innerHTML'), + self.assertRegex(element.get_attribute('innerHTML'), 'Tasks starting', 'build should show "tasks starting" status') # first task finished; check tasks progress bar
@@ -186,7 +186,7 @@ class TestMostRecentBuildsStates(SeleniumTestCase): selector = '[data-latest-build-result="%s"] ' \ '[data-build-state="Cancelling"]' % build.id element = self.wait_until_visible(selector) - self.assertRegexpMatches(element.get_attribute('innerHTML'), + self.assertRegex(element.get_attribute('innerHTML'), 'Cancelling the build', 'build should show "cancelling" status') # check cancelled state
@@ -198,5 +198,5 @@ class TestMostRecentBuildsStates(SeleniumTestCase): selector = '[data-latest-build-result="%s"] ' \ '[data-build-state="Cancelled"]' % build.id element = self.wait_until_visible(selector) - self.assertRegexpMatches(element.get_attribute('innerHTML'), + self.assertRegex(element.get_attribute('innerHTML'), 'Build cancelled', 'build should show "cancelled" status')
lib/toaster/tests/browser/test_new_custom_image_page.py +2 -2
@@ -136,7 +136,7 @@ class TestNewCustomImagePage(SeleniumTestCase): """ self._create_custom_image(self.recipe.name) element = self.wait_until_visible('#invalid-name-help') - self.assertRegexpMatches(element.text.strip(), + self.assertRegex(element.text.strip(), 'image with this name already exists') def test_new_duplicates_project_image(self):
@@ -154,4 +154,4 @@ class TestNewCustomImagePage(SeleniumTestCase): self._create_custom_image(custom_image_name) element = self.wait_until_visible('#invalid-name-help') expected = 'An image with this name already exists in this project' - self.assertRegexpMatches(element.text.strip(), expected) + self.assertRegex(element.text.strip(), expected)
Signature · 1 line
2.39.2
PATCH 3/3 toastermain/settings: Avoid python filehandle closure warnings
In reply to Richard PurdieSwitch to using with blocks when accessing files to ensure file descriptors are closed and avoid python warnings.
Signed-off-by Richard Purdie <[email protected]>
--- lib/toaster/toastermain/settings.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
lib/toaster/toastermain/settings.py +6 -3
@@ -89,14 +89,17 @@ else: from pytz.exceptions import UnknownTimeZoneError try: if pytz.timezone(zonename) is not None: - zonefilelist[hashlib.md5(open(filepath, 'rb').read()).hexdigest()] = zonename + with open(filepath, 'rb') as f: + zonefilelist[hashlib.md5(f.read()).hexdigest()] = zonename except UnknownTimeZoneError as ValueError: # we expect timezone failures here, just move over pass except ImportError: - zonefilelist[hashlib.md5(open(filepath, 'rb').read()).hexdigest()] = zonename + with open(filepath, 'rb') as f: + zonefilelist[hashlib.md5(f.read()).hexdigest()] = zonename - TIME_ZONE = zonefilelist[hashlib.md5(open('/etc/localtime', 'rb').read()).hexdigest()] + with open('/etc/localtime', 'rb') as f: + TIME_ZONE = zonefilelist[hashlib.md5(f.read()).hexdigest()] # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html
Signature · 1 line
2.39.2