@@ -22,7 +22,15 @@ def run_result(self, pytester: pytest.Pytester) -> pytest.RunResult:
22
22
(is (= "string" "string"))
23
23
(is (thrown? basilisp.lang.exception/ExceptionInfo (throw (ex-info "Exception" {}))))
24
24
(is (thrown? basilisp.lang.exception/ExceptionInfo (throw (python/Exception))))
25
- (is (throw (ex-info "Uncaught exception" {}))))
25
+ (is (throw (ex-info "Uncaught exception" {})))
26
+ (is (thrown-with-msg?
27
+ basilisp.lang.exception/ExceptionInfo
28
+ #"Caught exception"
29
+ (throw (ex-info "Caught exception message" {}))))
30
+ (is (thrown-with-msg?
31
+ basilisp.lang.exception/ExceptionInfo
32
+ #"Known exception"
33
+ (throw (ex-info "Unexpected exception" {})))))
26
34
27
35
(testing "are assertions"
28
36
(are [exp actual] (= exp actual)
@@ -37,14 +45,20 @@ def run_result(self, pytester: pytest.Pytester) -> pytest.RunResult:
37
45
(deftest error-test
38
46
(throw
39
47
(ex-info "This test will count as an error." {})))
48
+
49
+ ;; Test that syntax quoted forms still get expanded correctly into assertions
50
+ (defmacro syntax-quote-test-make []
51
+ `(deftest syntax-quote-seq-test
52
+ (is (= 5 4))))
53
+ (syntax-quote-test-make)
40
54
"""
41
55
pytester .makefile (".lpy" , test_testrunner = code )
42
56
pytester .syspathinsert ()
43
57
yield pytester .runpytest ()
44
58
runtime .Namespace .remove (sym .symbol ("test-testrunner" ))
45
59
46
60
def test_outcomes (self , run_result : pytest .RunResult ):
47
- run_result .assert_outcomes (passed = 1 , failed = 2 )
61
+ run_result .assert_outcomes (passed = 1 , failed = 3 )
48
62
49
63
def test_failure_repr (self , run_result : pytest .RunResult ):
50
64
run_result .stdout .fnmatch_lines (
@@ -65,7 +79,19 @@ def test_failure_repr(self, run_result: pytest.RunResult):
65
79
"" ,
66
80
" expected: <class 'basilisp.lang.exception.ExceptionInfo'>" ,
67
81
" actual: Exception()" ,
68
- ]
82
+ ],
83
+ consecutive = True ,
84
+ )
85
+
86
+ run_result .stdout .fnmatch_lines (
87
+ [
88
+ "FAIL in (assertion-test) (test_testrunner.lpy:17)" ,
89
+ " is assertions :: Regex pattern did not match" ,
90
+ "" ,
91
+ ' expected: #"Known exception"' ,
92
+ ' actual: "Unexpected exception {}"' ,
93
+ ],
94
+ consecutive = True ,
69
95
)
70
96
71
97
run_result .stdout .fnmatch_lines (
@@ -81,6 +107,17 @@ def test_failure_repr(self, run_result: pytest.RunResult):
81
107
consecutive = True ,
82
108
)
83
109
110
+ run_result .stdout .fnmatch_lines (
111
+ [
112
+ "FAIL in (syntax-quote-seq-test) (test_testrunner.lpy)" ,
113
+ " Test failure: (basilisp.core/= 5 4)" ,
114
+ "" ,
115
+ " expected: 5" ,
116
+ " actual: 4" ,
117
+ ],
118
+ consecutive = True ,
119
+ )
120
+
84
121
@pytest .mark .xfail (
85
122
platform .python_implementation () == "PyPy" and sys .version_info < (3 , 9 ),
86
123
reason = (
@@ -95,7 +132,7 @@ def test_error_repr(self, run_result: pytest.RunResult):
95
132
"" ,
96
133
"Traceback (most recent call last):" ,
97
134
' File "*test_testrunner.lpy", line 12, in assertion_test' ,
98
- ' (is (throw (ex-info "Uncaught exception" {})))) ' ,
135
+ ' (is (throw (ex-info "Uncaught exception" {})))' ,
99
136
"basilisp.lang.exception.ExceptionInfo: Uncaught exception {}" ,
100
137
]
101
138
else :
@@ -104,8 +141,7 @@ def test_error_repr(self, run_result: pytest.RunResult):
104
141
"" ,
105
142
"Traceback (most recent call last):" ,
106
143
' File "*test_testrunner.lpy", line 12, in assertion_test' ,
107
- ' (is (throw (ex-info "Uncaught exception" {}))))' ,
108
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" ,
144
+ ' (is (throw (ex-info "Uncaught exception" {})))' ,
109
145
"basilisp.lang.exception.ExceptionInfo: Uncaught exception {}" ,
110
146
]
111
147
@@ -118,7 +154,7 @@ def test_error_repr(self, run_result: pytest.RunResult):
118
154
[
119
155
"ERROR in (error-test) (test_testrunner.lpy)" ,
120
156
"Traceback (most recent call last):" ,
121
- ' File "*test_testrunner.lpy", line 25 , in error_test' ,
157
+ ' File "*test_testrunner.lpy", line 33 , in error_test' ,
122
158
" (throw" ,
123
159
"basilisp.lang.exception.ExceptionInfo: This test will count as an error. {}" ,
124
160
]
0 commit comments