Skip to content

Commit f1ec6b7

Browse files
authored
Fix issue with test/is expected value misreporting on failure (#966)
Hi, could you please consider patch to correct the reporting on the expected outcome of `basilisp.test/is` when expr falls in the :default handling. It fixes #965. I've included a test case for a function call expr, even though there was a case for `(is false)` which I've also updated. Thanks Co-authored-by: ikappaki <[email protected]>
1 parent d1abb8a commit f1ec6b7

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
### Fixed
1212
* Fixed an issue where attempting to run a namespace from the CLI could fail in certain cases (#957)
1313
* Fixed an issue with `keep` and `keep-indexed` two-arity forms not preserving the transformed values (#962)
14+
* Fixed an issue with `basilisp.test/is` where the expected value was misreported on failure of non `(= ...)` expr (#965)
1415

1516
## [v0.1.0]
1617
### Added

src/basilisp/test.lpy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
:message ~msg
185185
:expr (quote ~expr)
186186
:actual computed#
187-
:expected computed#
187+
:expected (list (symbol "not") computed#)
188188
:line ~line-num
189189
:type :failure}))))
190190

tests/basilisp/testrunner_test.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def run_result(self, pytester: pytest.Pytester) -> pytest.RunResult:
1919
(testing "is assertions"
2020
(is true)
2121
(is false)
22+
(is (some #{5} #{6 7}))
23+
(is (some #{7} #{6 7}))
2224
(is (= "string" "string"))
2325
(is (thrown? basilisp.lang.exception/ExceptionInfo (throw (ex-info "Exception" {}))))
2426
(is (thrown? basilisp.lang.exception/ExceptionInfo (throw (python/Exception))))
@@ -66,15 +68,26 @@ def test_failure_repr(self, run_result: pytest.RunResult):
6668
"FAIL in (assertion-test) (test_testrunner.lpy:8)",
6769
" is assertions :: Test failure: false",
6870
"",
69-
" expected: false",
71+
" expected: (not false)",
7072
" actual: false",
7173
],
7274
consecutive=True,
7375
)
7476

7577
run_result.stdout.fnmatch_lines(
7678
[
77-
"FAIL in (assertion-test) (test_testrunner.lpy:11)",
79+
"FAIL in (assertion-test) (test_testrunner.lpy:9)",
80+
" is assertions :: Test failure: (some #{5} #{6 7})",
81+
"",
82+
" expected: (not nil)",
83+
" actual: nil",
84+
],
85+
consecutive=True,
86+
)
87+
88+
run_result.stdout.fnmatch_lines(
89+
[
90+
"FAIL in (assertion-test) (test_testrunner.lpy:13)",
7891
" is assertions :: Expected <class 'basilisp.lang.exception.ExceptionInfo'>; got <class 'Exception'> instead",
7992
"",
8093
" expected: <class 'basilisp.lang.exception.ExceptionInfo'>",
@@ -85,7 +98,7 @@ def test_failure_repr(self, run_result: pytest.RunResult):
8598

8699
run_result.stdout.fnmatch_lines(
87100
[
88-
"FAIL in (assertion-test) (test_testrunner.lpy:17)",
101+
"FAIL in (assertion-test) (test_testrunner.lpy:19)",
89102
" is assertions :: Regex pattern did not match",
90103
"",
91104
' expected: #"Known exception"',
@@ -128,19 +141,19 @@ def test_failure_repr(self, run_result: pytest.RunResult):
128141
def test_error_repr(self, run_result: pytest.RunResult):
129142
if sys.version_info < (3, 11):
130143
expected = [
131-
"ERROR in (assertion-test) (test_testrunner.lpy:12)",
144+
"ERROR in (assertion-test) (test_testrunner.lpy:14)",
132145
"",
133146
"Traceback (most recent call last):",
134-
' File "*test_testrunner.lpy", line 12, in assertion_test',
147+
' File "*test_testrunner.lpy", line 14, in assertion_test',
135148
' (is (throw (ex-info "Uncaught exception" {})))',
136149
"basilisp.lang.exception.ExceptionInfo: Uncaught exception {}",
137150
]
138151
else:
139152
expected = [
140-
"ERROR in (assertion-test) (test_testrunner.lpy:12)",
153+
"ERROR in (assertion-test) (test_testrunner.lpy:14)",
141154
"",
142155
"Traceback (most recent call last):",
143-
' File "*test_testrunner.lpy", line 12, in assertion_test',
156+
' File "*test_testrunner.lpy", line 14, in assertion_test',
144157
' (is (throw (ex-info "Uncaught exception" {})))',
145158
"basilisp.lang.exception.ExceptionInfo: Uncaught exception {}",
146159
]
@@ -154,7 +167,7 @@ def test_error_repr(self, run_result: pytest.RunResult):
154167
[
155168
"ERROR in (error-test) (test_testrunner.lpy)",
156169
"Traceback (most recent call last):",
157-
' File "*test_testrunner.lpy", line 33, in error_test',
170+
' File "*test_testrunner.lpy", line 35, in error_test',
158171
" (throw",
159172
"basilisp.lang.exception.ExceptionInfo: This test will count as an error. {}",
160173
]

0 commit comments

Comments
 (0)