Merge ~jugmac00/lpci:compare-crafterrors-directly into lpci:main

Proposed by Jürgen Gmach
Status: Merged
Merged at revision: 1fc0863a93e8fdbb3271fa659bbfa0e74c64e855
Proposed branch: ~jugmac00/lpci:compare-crafterrors-directly
Merge into: lpci:main
Diff against target: 94 lines (+13/-14)
4 files modified
lpcraft/tests/test_main.py (+8/-10)
requirements.in (+1/-1)
requirements.txt (+3/-3)
setup.cfg (+1/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+412595@code.launchpad.net

Commit message

Directly compare CraftErrors

Description of the change

Since https://github.com/canonical/craft-cli/pull/41 has landed, you
can compare CraftError objects directly, so there is no more need to
compare the string representation.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lpcraft/tests/test_main.py b/lpcraft/tests/test_main.py
2index e8808e5..ee74882 100644
3--- a/lpcraft/tests/test_main.py
4+++ b/lpcraft/tests/test_main.py
5@@ -2,9 +2,9 @@
6 # GNU General Public License version 3 (see the file LICENSE).
7
8 import sys
9-from unittest.mock import patch
10+from unittest.mock import call, patch
11
12-from craft_cli import EmitterMode
13+from craft_cli import CraftError, EmitterMode
14 from fixtures import MockPatch
15 from testtools import TestCase
16
17@@ -54,11 +54,9 @@ class TestMain(TestCase):
18 ret = main()
19
20 self.assertEqual(1, ret)
21- # cannot compare the results directly but only the str representation
22- # see https://github.com/canonical/craft-cli/issues/40
23 self.assertEqual(
24- "call('error', CraftError('Interrupted.'))",
25- str(emitter.recorder.interactions[0]),
26+ call("error", CraftError("Interrupted.")),
27+ emitter.recorder.interactions[0],
28 )
29
30 @patch("lpcraft.main.run")
31@@ -70,11 +68,11 @@ class TestMain(TestCase):
32 ret = main()
33
34 self.assertEqual(1, ret)
35- # cannot compare the results directly but only the str representation
36- # see https://github.com/canonical/craft-cli/issues/40
37 self.assertEqual(
38- "call('error', CraftError('lpcraft internal error: RuntimeError()'))", # noqa: E501
39- str(emitter.recorder.interactions[0]),
40+ call(
41+ "error", CraftError("lpcraft internal error: RuntimeError()")
42+ ),
43+ emitter.recorder.interactions[0],
44 )
45
46 def test_quiet_mode(self):
47diff --git a/requirements.in b/requirements.in
48index a5db10c..422bc41 100644
49--- a/requirements.in
50+++ b/requirements.in
51@@ -2,4 +2,4 @@ craft-providers
52 pydantic
53 PyYAML
54 python-dotenv
55-git+git://github.com/canonical/craft-cli.git@c172fa00f61dff8e510116d1c23258e79f710e38
56+git+git://github.com/canonical/craft-cli.git@93db67c7bc357f0b6d9f5793b7c2381c306f9ca3
57diff --git a/requirements.txt b/requirements.txt
58index 107582d..f81e3ac 100644
59--- a/requirements.txt
60+++ b/requirements.txt
61@@ -4,18 +4,18 @@
62 #
63 # pip-compile
64 #
65-appdirs==1.4.4
66- # via craft-cli
67 certifi==2021.10.8
68 # via requests
69 charset-normalizer==2.0.7
70 # via requests
71-craft-cli @ git+git://github.com/canonical/craft-cli.git@c172fa00f61dff8e510116d1c23258e79f710e38
72+craft-cli @ git+git://github.com/canonical/craft-cli.git@93db67c7bc357f0b6d9f5793b7c2381c306f9ca3
73 # via -r requirements.in
74 craft-providers==1.0.3
75 # via -r requirements.in
76 idna==3.3
77 # via requests
78+platformdirs==2.4.0
79+ # via craft-cli
80 pydantic==1.8.2
81 # via
82 # -r requirements.in
83diff --git a/setup.cfg b/setup.cfg
84index 4d14610..a1a9ef9 100644
85--- a/setup.cfg
86+++ b/setup.cfg
87@@ -37,6 +37,7 @@ console_scripts =
88 test =
89 coverage
90 fixtures
91+ pdbpp
92 pytest
93 systemfixtures
94 testtools

Subscribers

People subscribed via source and target branches