[FIX]In macros, from python2/3 form
This commit is contained in:
parent
cda0282a33
commit
2f5b50dcef
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2020 Fabien Bourgeois <fabien@yaltik.com>
|
# Copyright 2020-2021 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as
|
# it under the terms of the GNU Affero General Public License as
|
||||||
@ -16,4 +16,4 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import hy
|
import hy
|
||||||
from . import macros,odoo, xml_base, test
|
import odoo, xml_base, test
|
||||||
|
@ -28,3 +28,16 @@
|
|||||||
(defmacro ustr-cast [s]
|
(defmacro ustr-cast [s]
|
||||||
"If python2, return unicode casting, else str casting"
|
"If python2, return unicode casting, else str casting"
|
||||||
(if-python2 `(unicode ~s) `(str ~s)))
|
(if-python2 `(unicode ~s) `(str ~s)))
|
||||||
|
|
||||||
|
(defmacro hydict [dic]
|
||||||
|
"Generate dict with mangled keys, from HyDict list"
|
||||||
|
(setv mangled-dic
|
||||||
|
(list
|
||||||
|
(map
|
||||||
|
(fn [pair]
|
||||||
|
(if (even? (nth pair 0))
|
||||||
|
(mangle (nth pair 1))
|
||||||
|
(nth pair 1)))
|
||||||
|
(enumerate dic))))
|
||||||
|
`{~@mangled-dic})
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
" Hy Odoo Tests Helpers and Macros "
|
" Hy Odoo Tests Helpers and Macros "
|
||||||
|
|
||||||
|
(require [hy-odoo.macros.general [if-python2]])
|
||||||
|
|
||||||
(defmacro o-assert-equal [left right] `(.assertEqual self ~left ~right))
|
(defmacro o-assert-equal [left right] `(.assertEqual self ~left ~right))
|
||||||
(defmacro o-assert-list-equal [left right] `(.assertListEqual self ~left ~right))
|
(defmacro o-assert-list-equal [left right] `(.assertListEqual self ~left ~right))
|
||||||
(defmacro o-assert-dict-equal [left right] `(.assertDictEqual self ~left ~right))
|
(defmacro o-assert-dict-equal [left right] `(.assertDictEqual self ~left ~right))
|
||||||
@ -32,7 +34,10 @@
|
|||||||
(defmacro o-assert-is-instance [left right] `(.assertIsInstance self ~left ~right))
|
(defmacro o-assert-is-instance [left right] `(.assertIsInstance self ~left ~right))
|
||||||
(defmacro o-assert-not-is-instance [left right] `(.assertNotIsInstance self ~left ~right))
|
(defmacro o-assert-not-is-instance [left right] `(.assertNotIsInstance self ~left ~right))
|
||||||
(defmacro o-assert-raises [Error] `(.assertRaises self ~Error))
|
(defmacro o-assert-raises [Error] `(.assertRaises self ~Error))
|
||||||
(defmacro o-assert-raises-regex [Error regexp] `(.assertRaisesRegexp self ~Error ~regexp))
|
(defmacro o-assert-raises-regex [Error regexp]
|
||||||
|
(if-python2
|
||||||
|
`(.assertRaisesRegexp self ~Error ~regexp)
|
||||||
|
`(.assertRaisesRegex self ~Error ~regexp)))
|
||||||
|
|
||||||
(defmacro odo-assert-raises [Error body]
|
(defmacro odo-assert-raises [Error body]
|
||||||
"Macro to test Error with self.assertRaises and do block"
|
"Macro to test Error with self.assertRaises and do block"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user