1import warnings
2from unittest.mock import patch
3
4import pyexcel.ext.ods
5import pyexcel.ext.xls
6import pyexcel.ext.ods3
7import pyexcel.ext.text
8import pyexcel.ext.xlsx
9
10try:
11    reload
12except NameError:
13    from imp import reload
14
15EXPECTED_DEPRECATION_MESSAGE = (
16    "Deprecated usage since v%s! "
17    + "Explicit import is no longer required. pyexcel.ext.%s is auto imported."
18)
19
20
21@patch.object(warnings, "warn")
22def test_ods_note(warn):
23    reload(pyexcel.ext.ods)
24    warn.assert_called_with(EXPECTED_DEPRECATION_MESSAGE % ("0.2.2", "ods"))
25
26
27@patch.object(warnings, "warn")
28def test_ods3_note(warn):
29    reload(pyexcel.ext.ods3)
30    warn.assert_called_with(EXPECTED_DEPRECATION_MESSAGE % ("0.2.2", "ods3"))
31
32
33@patch.object(warnings, "warn")
34def test_xls_note(warn):
35    reload(pyexcel.ext.xls)
36    warn.assert_called_with(EXPECTED_DEPRECATION_MESSAGE % ("0.2.2", "xls"))
37
38
39@patch.object(warnings, "warn")
40def test_xlsx_note(warn):
41    reload(pyexcel.ext.xlsx)
42    warn.assert_called_with(EXPECTED_DEPRECATION_MESSAGE % ("0.2.2", "xlsx"))
43
44
45@patch.object(warnings, "warn")
46def test_text_note(warn):
47    reload(pyexcel.ext.text)
48    warn.assert_called_with(EXPECTED_DEPRECATION_MESSAGE % ("0.2.1", "text"))
49