← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~jugmac00/lpcraft:compare-crafterrors-directly into lpcraft:main

 

Jürgen Gmach has proposed merging ~jugmac00/lpcraft:compare-crafterrors-directly into lpcraft:main.

Commit message:
Directly compare CraftErrors

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jugmac00/lpcraft/+git/lpcraft/+merge/412595

Since https://github.com/canonical/craft-cli/pull/41 you can compare
CraftError objects, so there is no more need to compare the string
representation.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~jugmac00/lpcraft:compare-crafterrors-directly into lpcraft:main.
diff --git a/lpcraft/tests/test_main.py b/lpcraft/tests/test_main.py
index e8808e5..bc47855 100644
--- a/lpcraft/tests/test_main.py
+++ b/lpcraft/tests/test_main.py
@@ -2,9 +2,9 @@
 # GNU General Public License version 3 (see the file LICENSE).
 
 import sys
-from unittest.mock import patch
+from unittest.mock import call, patch
 
-from craft_cli import EmitterMode
+from craft_cli import CraftError, EmitterMode
 from fixtures import MockPatch
 from testtools import TestCase
 
@@ -54,11 +54,9 @@ class TestMain(TestCase):
             ret = main()
 
         self.assertEqual(1, ret)
-        # cannot compare the results directly but only the str representation
-        # see https://github.com/canonical/craft-cli/issues/40
         self.assertEqual(
-            "call('error', CraftError('Interrupted.'))",
-            str(emitter.recorder.interactions[0]),
+            call("error", CraftError("Interrupted.")),
+            emitter.recorder.interactions[0],
         )
 
     @patch("lpcraft.main.run")
@@ -70,11 +68,11 @@ class TestMain(TestCase):
             ret = main()
 
         self.assertEqual(1, ret)
-        # cannot compare the results directly but only the str representation
-        # see https://github.com/canonical/craft-cli/issues/40
         self.assertEqual(
-            "call('error', CraftError('lpcraft internal error: RuntimeError()'))",  # noqa: E501
-            str(emitter.recorder.interactions[0]),
+            call(
+                "error", CraftError("lpcraft internal error: RuntimeError()")
+            ),  # noqa: E501
+            emitter.recorder.interactions[0],
         )
 
     def test_quiet_mode(self):
diff --git a/requirements.in b/requirements.in
index a5db10c..422bc41 100644
--- a/requirements.in
+++ b/requirements.in
@@ -2,4 +2,4 @@ craft-providers
 pydantic
 PyYAML
 python-dotenv
-git+git://github.com/canonical/craft-cli.git@c172fa00f61dff8e510116d1c23258e79f710e38
+git+git://github.com/canonical/craft-cli.git@93db67c7bc357f0b6d9f5793b7c2381c306f9ca3
diff --git a/requirements.txt b/requirements.txt
index 107582d..f81e3ac 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,18 +4,18 @@
 #
 #    pip-compile
 #
-appdirs==1.4.4
-    # via craft-cli
 certifi==2021.10.8
     # via requests
 charset-normalizer==2.0.7
     # via requests
-craft-cli @ git+git://github.com/canonical/craft-cli.git@c172fa00f61dff8e510116d1c23258e79f710e38
+craft-cli @ git+git://github.com/canonical/craft-cli.git@93db67c7bc357f0b6d9f5793b7c2381c306f9ca3
     # via -r requirements.in
 craft-providers==1.0.3
     # via -r requirements.in
 idna==3.3
     # via requests
+platformdirs==2.4.0
+    # via craft-cli
 pydantic==1.8.2
     # via
     #   -r requirements.in
diff --git a/setup.cfg b/setup.cfg
index 4d14610..a1a9ef9 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -37,6 +37,7 @@ console_scripts =
 test =
     coverage
     fixtures
+    pdbpp
     pytest
     systemfixtures
     testtools

Follow ups