hy/tests/native_tests/py3_only_tests.hy
Allison Kaptur caa53fb095 Tests for explicit exception chaining
This also breaks out the PY3 only tests into their own file.  We need to do this because raise from is a syntax error in PY2, so we can't rely on the previous hack of catching a HyCompileError - it would compile fine through Hy and then be a syntax error in Python.
2014-05-01 16:33:10 -04:00

16 lines
500 B
Hy

;; Tests where the emited code relies on Python 3.
;; Conditionally included in nosetests runs.
(defn test-yield-from []
"NATIVE: testing yield from"
(do (defn yield-from-test []
(for* [i (range 3)]
(yield i))
(yield-from [1 2 3]))
(assert (= (list (yield-from-test)) [0 1 2 1 2 3]))))
(defn test-exception-cause []
(try (raise ValueError :from NameError)
(except [e [ValueError]]
(assert (= (type (. e __cause__)) NameError)))))