summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMinoru TAKAHASHI <takahashi.minoru7@gmail.com>2016-05-10 13:58:04 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-05-13 22:17:25 +0900
commit33d1023368492196139f1e749a085c363895af10 (patch)
tree476b62d5082e769a2b01c6c748f3dca36790f304
parentc66b4b34e5d6fd71d999276a9413411682317044 (diff)
test_import_module: Update test cases
Because Python does not provides features to unimport modules which ware imported before, this patch separates dummy modules to test import features of Ryu. e.g.) If 'aaa' was imported in the previous test case, 'aaa' affects the subsequent test cases. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/tests/unit/lib/test_import_module.py54
-rw-r--r--ryu/tests/unit/lib/test_mod/aaa/__init__.py (renamed from ryu/tests/unit/lib/test_mod/fuga/__init__.py)0
-rw-r--r--ryu/tests/unit/lib/test_mod/aaa/mod.py (renamed from ryu/tests/unit/lib/test_mod/fuga/mod.py)2
-rw-r--r--ryu/tests/unit/lib/test_mod/bbb/__init__.py (renamed from ryu/tests/unit/lib/test_mod/hoge/__init__.py)0
-rw-r--r--ryu/tests/unit/lib/test_mod/bbb/mod.py (renamed from ryu/tests/unit/lib/test_mod/hoge/mod.py)2
-rw-r--r--ryu/tests/unit/lib/test_mod/ccc/__init__.py14
-rw-r--r--ryu/tests/unit/lib/test_mod/ccc/mod.py16
-rw-r--r--ryu/tests/unit/lib/test_mod/ddd/__init__.py14
-rw-r--r--ryu/tests/unit/lib/test_mod/ddd/mod.py16
-rw-r--r--ryu/tests/unit/lib/test_mod/eee.py16
-rw-r--r--ryu/tests/unit/lib/test_mod/fff.py16
-rw-r--r--ryu/tests/unit/lib/test_mod/ggg.py16
12 files changed, 135 insertions, 31 deletions
diff --git a/ryu/tests/unit/lib/test_import_module.py b/ryu/tests/unit/lib/test_import_module.py
index 71ff984b..25264c36 100644
--- a/ryu/tests/unit/lib/test_import_module.py
+++ b/ryu/tests/unit/lib/test_import_module.py
@@ -18,18 +18,12 @@ import unittest
from nose.tools import eq_
from ryu.utils import import_module
-import ryu.tests.unit.lib.test_mod.fuga.mod
class Test_import_module(unittest.TestCase):
- """ Test case for ryu.utils.import_module
"""
-
- def setUp(self):
- pass
-
- def tearDown(self):
- pass
+ Test case for ryu.utils.import_module
+ """
@staticmethod
def _my_import(name):
@@ -40,32 +34,34 @@ class Test_import_module(unittest.TestCase):
return mod
def test_import_module_with_same_basename(self):
- fuga = import_module('ryu.tests.unit.lib.test_mod.fuga.mod')
- eq_("this is fuga", fuga.name)
- hoge = import_module('ryu.tests.unit.lib.test_mod.hoge.mod')
- eq_("this is hoge", hoge.name)
+ aaa = import_module('ryu.tests.unit.lib.test_mod.aaa.mod')
+ eq_("this is aaa", aaa.name)
+ bbb = import_module('ryu.tests.unit.lib.test_mod.bbb.mod')
+ eq_("this is bbb", bbb.name)
def test_import_module_by_filename(self):
- fuga = import_module('./lib/test_mod/fuga/mod.py')
- eq_("this is fuga", fuga.name)
- hoge = import_module('./lib/test_mod/hoge/mod.py')
- eq_("this is hoge", hoge.name)
+ ccc = import_module('./lib/test_mod/ccc/mod.py')
+ eq_("this is ccc", ccc.name)
+ ddd = import_module('./lib/test_mod/ddd/mod.py')
+ # Note: When importing a module by filename, if module file name
+ # is duplicated, import_module returns a module instance which is
+ # imported before.
+ eq_("this is ccc", ddd.name)
def test_import_same_module1(self):
- fuga1 = import_module('./lib/test_mod/fuga/mod.py')
- eq_("this is fuga", fuga1.name)
- eq_(ryu.tests.unit.lib.test_mod.fuga.mod, fuga1)
+ from ryu.tests.unit.lib.test_mod import eee as eee1
+ eq_("this is eee", eee1.name)
+ eee2 = import_module('./lib/test_mod/eee.py')
+ eq_("this is eee", eee2.name)
def test_import_same_module2(self):
- fuga1 = import_module('./lib/test_mod/fuga/mod.py')
- eq_("this is fuga", fuga1.name)
- fuga2 = import_module('ryu.tests.unit.lib.test_mod.fuga.mod')
- eq_("this is fuga", fuga2.name)
- eq_(fuga1, fuga2)
+ fff1 = import_module('./lib/test_mod/fff.py')
+ eq_("this is fff", fff1.name)
+ fff2 = import_module('ryu.tests.unit.lib.test_mod.fff')
+ eq_("this is fff", fff2.name)
def test_import_same_module3(self):
- fuga1 = import_module('./lib/test_mod/fuga/mod.py')
- eq_("this is fuga", fuga1.name)
- fuga3 = self._my_import('ryu.tests.unit.lib.test_mod.fuga.mod')
- eq_("this is fuga", fuga3.name)
- eq_(fuga1, fuga3)
+ ggg1 = import_module('./lib/test_mod/ggg.py')
+ eq_("this is ggg", ggg1.name)
+ ggg2 = self._my_import('ryu.tests.unit.lib.test_mod.ggg')
+ eq_("this is ggg", ggg2.name)
diff --git a/ryu/tests/unit/lib/test_mod/fuga/__init__.py b/ryu/tests/unit/lib/test_mod/aaa/__init__.py
index ca8ef539..ca8ef539 100644
--- a/ryu/tests/unit/lib/test_mod/fuga/__init__.py
+++ b/ryu/tests/unit/lib/test_mod/aaa/__init__.py
diff --git a/ryu/tests/unit/lib/test_mod/fuga/mod.py b/ryu/tests/unit/lib/test_mod/aaa/mod.py
index 551cb6c0..a5eff136 100644
--- a/ryu/tests/unit/lib/test_mod/fuga/mod.py
+++ b/ryu/tests/unit/lib/test_mod/aaa/mod.py
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-name = "this is fuga"
+name = "this is aaa"
diff --git a/ryu/tests/unit/lib/test_mod/hoge/__init__.py b/ryu/tests/unit/lib/test_mod/bbb/__init__.py
index ca8ef539..ca8ef539 100644
--- a/ryu/tests/unit/lib/test_mod/hoge/__init__.py
+++ b/ryu/tests/unit/lib/test_mod/bbb/__init__.py
diff --git a/ryu/tests/unit/lib/test_mod/hoge/mod.py b/ryu/tests/unit/lib/test_mod/bbb/mod.py
index 2f363d0b..397c8554 100644
--- a/ryu/tests/unit/lib/test_mod/hoge/mod.py
+++ b/ryu/tests/unit/lib/test_mod/bbb/mod.py
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-name = "this is hoge"
+name = "this is bbb"
diff --git a/ryu/tests/unit/lib/test_mod/ccc/__init__.py b/ryu/tests/unit/lib/test_mod/ccc/__init__.py
new file mode 100644
index 00000000..ce07156d
--- /dev/null
+++ b/ryu/tests/unit/lib/test_mod/ccc/__init__.py
@@ -0,0 +1,14 @@
+# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
+#
+# 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/ccc/mod.py b/ryu/tests/unit/lib/test_mod/ccc/mod.py
new file mode 100644
index 00000000..5be826cf
--- /dev/null
+++ b/ryu/tests/unit/lib/test_mod/ccc/mod.py
@@ -0,0 +1,16 @@
+# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
+#
+# 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.
+
+name = "this is ccc"
diff --git a/ryu/tests/unit/lib/test_mod/ddd/__init__.py b/ryu/tests/unit/lib/test_mod/ddd/__init__.py
new file mode 100644
index 00000000..ce07156d
--- /dev/null
+++ b/ryu/tests/unit/lib/test_mod/ddd/__init__.py
@@ -0,0 +1,14 @@
+# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
+#
+# 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/ddd/mod.py b/ryu/tests/unit/lib/test_mod/ddd/mod.py
new file mode 100644
index 00000000..31d31d53
--- /dev/null
+++ b/ryu/tests/unit/lib/test_mod/ddd/mod.py
@@ -0,0 +1,16 @@
+# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
+#
+# 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.
+
+name = "this is ddd"
diff --git a/ryu/tests/unit/lib/test_mod/eee.py b/ryu/tests/unit/lib/test_mod/eee.py
new file mode 100644
index 00000000..ed21a8aa
--- /dev/null
+++ b/ryu/tests/unit/lib/test_mod/eee.py
@@ -0,0 +1,16 @@
+# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
+#
+# 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.
+
+name = "this is eee"
diff --git a/ryu/tests/unit/lib/test_mod/fff.py b/ryu/tests/unit/lib/test_mod/fff.py
new file mode 100644
index 00000000..5a565e38
--- /dev/null
+++ b/ryu/tests/unit/lib/test_mod/fff.py
@@ -0,0 +1,16 @@
+# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
+#
+# 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.
+
+name = "this is fff"
diff --git a/ryu/tests/unit/lib/test_mod/ggg.py b/ryu/tests/unit/lib/test_mod/ggg.py
new file mode 100644
index 00000000..29555e56
--- /dev/null
+++ b/ryu/tests/unit/lib/test_mod/ggg.py
@@ -0,0 +1,16 @@
+# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
+#
+# 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.
+
+name = "this is ggg"