Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
ryu/tests/unit/lib/test_import_module.py | 11 ++++++++++
.../unit/lib/test_mod/no_double_import/__init__.py | 15 +++++++++++++
.../unit/lib/test_mod/no_double_import/mod.py | 25 ++++++++++++++++++++++
3 files changed, 51 insertions(+)
create mode 100644 ryu/tests/unit/lib/test_mod/no_double_import/__init__.py
create mode 100644 ryu/tests/unit/lib/test_mod/no_double_import/mod.py
diff --git a/ryu/tests/unit/lib/test_import_module.py
b/ryu/tests/unit/lib/test_import_module.py
index 2c62f6e..784ae74 100644
--- a/ryu/tests/unit/lib/test_import_module.py
+++ b/ryu/tests/unit/lib/test_import_module.py
@@ -20,6 +20,7 @@ from nose.tools import eq_
from ryu.utils import import_module
import ryu.tests.unit.lib.test_mod.fuga.mod
+import ryu.tests.unit.lib.test_mod.no_double_import.mod
class Test_import_module(unittest.TestCase):
@@ -83,3 +84,13 @@ class Test_import_module(unittest.TestCase):
# if it can be a problem, it's the module's responsibility to deal
# with it.
ok_(fuga1 != fuga3)
+
+ def test_import_same_module4(self):
+ ndbl1 = import_module('./lib/test_mod/no_double_import/mod.py')
+ eq_("this is no_double_import", ndbl1.name)
+ eq_(ryu.tests.unit.lib.test_mod.no_double_import.mod, ndbl1)
+ hoge1 = import_module('./lib/test_mod/hoge/mod.py')
+ eq_("this is hoge", hoge1.name)
+ ndbl2 = import_module('./lib/test_mod/no_double_import/mod.py')
+ eq_("this is no_double_import", ndbl2.name)
+ eq_(ryu.tests.unit.lib.test_mod.no_double_import.mod, ndbl2)
diff --git a/ryu/tests/unit/lib/test_mod/no_double_import/__init__.py
b/ryu/tests/unit/lib/test_mod/no_double_import/__init__.py
new file mode 100644
index 0000000..ca8ef53
--- /dev/null
+++ b/ryu/tests/unit/lib/test_mod/no_double_import/__init__.py
@@ -0,0 +1,15 @@
+# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
+# Copyright (C) 2013 YAMAMOTO Takashi <yamamoto at valinux co jp>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/ryu/tests/unit/lib/test_mod/no_double_import/mod.py
b/ryu/tests/unit/lib/test_mod/no_double_import/mod.py
new file mode 100644
index 0000000..095232d
--- /dev/null
+++ b/ryu/tests/unit/lib/test_mod/no_double_import/mod.py
@@ -0,0 +1,25 @@
+# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
+# Copyright (C) 2013 YAMAMOTO Takashi <yamamoto at valinux co jp>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import sys
+from ryu.exception import DoubleImport
+
+name = "this is no_double_import"
+
+# detect double import of this module
+if hasattr(sys, '_import_test'):
+ raise DoubleImport(module=__name__)
+sys._import_test = __name__
--
1.8.3.1
------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel