From 33d1023368492196139f1e749a085c363895af10 Mon Sep 17 00:00:00 2001 From: Minoru TAKAHASHI Date: Tue, 10 May 2016 13:58:04 +0900 Subject: 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 Signed-off-by: FUJITA Tomonori --- ryu/tests/unit/lib/test_import_module.py | 54 +++++++++++++--------------- ryu/tests/unit/lib/test_mod/aaa/__init__.py | 15 ++++++++ ryu/tests/unit/lib/test_mod/aaa/mod.py | 17 +++++++++ ryu/tests/unit/lib/test_mod/bbb/__init__.py | 15 ++++++++ ryu/tests/unit/lib/test_mod/bbb/mod.py | 17 +++++++++ ryu/tests/unit/lib/test_mod/ccc/__init__.py | 14 ++++++++ ryu/tests/unit/lib/test_mod/ccc/mod.py | 16 +++++++++ ryu/tests/unit/lib/test_mod/ddd/__init__.py | 14 ++++++++ ryu/tests/unit/lib/test_mod/ddd/mod.py | 16 +++++++++ ryu/tests/unit/lib/test_mod/eee.py | 16 +++++++++ ryu/tests/unit/lib/test_mod/fff.py | 16 +++++++++ ryu/tests/unit/lib/test_mod/fuga/__init__.py | 15 -------- ryu/tests/unit/lib/test_mod/fuga/mod.py | 17 --------- ryu/tests/unit/lib/test_mod/ggg.py | 16 +++++++++ ryu/tests/unit/lib/test_mod/hoge/__init__.py | 15 -------- ryu/tests/unit/lib/test_mod/hoge/mod.py | 17 --------- 16 files changed, 197 insertions(+), 93 deletions(-) create mode 100644 ryu/tests/unit/lib/test_mod/aaa/__init__.py create mode 100644 ryu/tests/unit/lib/test_mod/aaa/mod.py create mode 100644 ryu/tests/unit/lib/test_mod/bbb/__init__.py create mode 100644 ryu/tests/unit/lib/test_mod/bbb/mod.py create mode 100644 ryu/tests/unit/lib/test_mod/ccc/__init__.py create mode 100644 ryu/tests/unit/lib/test_mod/ccc/mod.py create mode 100644 ryu/tests/unit/lib/test_mod/ddd/__init__.py create mode 100644 ryu/tests/unit/lib/test_mod/ddd/mod.py create mode 100644 ryu/tests/unit/lib/test_mod/eee.py create mode 100644 ryu/tests/unit/lib/test_mod/fff.py delete mode 100644 ryu/tests/unit/lib/test_mod/fuga/__init__.py delete mode 100644 ryu/tests/unit/lib/test_mod/fuga/mod.py create mode 100644 ryu/tests/unit/lib/test_mod/ggg.py delete mode 100644 ryu/tests/unit/lib/test_mod/hoge/__init__.py delete mode 100644 ryu/tests/unit/lib/test_mod/hoge/mod.py 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/aaa/__init__.py b/ryu/tests/unit/lib/test_mod/aaa/__init__.py new file mode 100644 index 00000000..ca8ef539 --- /dev/null +++ b/ryu/tests/unit/lib/test_mod/aaa/__init__.py @@ -0,0 +1,15 @@ +# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. +# Copyright (C) 2013 YAMAMOTO Takashi +# +# 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/aaa/mod.py b/ryu/tests/unit/lib/test_mod/aaa/mod.py new file mode 100644 index 00000000..a5eff136 --- /dev/null +++ b/ryu/tests/unit/lib/test_mod/aaa/mod.py @@ -0,0 +1,17 @@ +# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. +# Copyright (C) 2013 YAMAMOTO Takashi +# +# 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 aaa" diff --git a/ryu/tests/unit/lib/test_mod/bbb/__init__.py b/ryu/tests/unit/lib/test_mod/bbb/__init__.py new file mode 100644 index 00000000..ca8ef539 --- /dev/null +++ b/ryu/tests/unit/lib/test_mod/bbb/__init__.py @@ -0,0 +1,15 @@ +# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. +# Copyright (C) 2013 YAMAMOTO Takashi +# +# 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/bbb/mod.py b/ryu/tests/unit/lib/test_mod/bbb/mod.py new file mode 100644 index 00000000..397c8554 --- /dev/null +++ b/ryu/tests/unit/lib/test_mod/bbb/mod.py @@ -0,0 +1,17 @@ +# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. +# Copyright (C) 2013 YAMAMOTO Takashi +# +# 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 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/fuga/__init__.py b/ryu/tests/unit/lib/test_mod/fuga/__init__.py deleted file mode 100644 index ca8ef539..00000000 --- a/ryu/tests/unit/lib/test_mod/fuga/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. -# Copyright (C) 2013 YAMAMOTO Takashi -# -# 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/fuga/mod.py b/ryu/tests/unit/lib/test_mod/fuga/mod.py deleted file mode 100644 index 551cb6c0..00000000 --- a/ryu/tests/unit/lib/test_mod/fuga/mod.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. -# Copyright (C) 2013 YAMAMOTO Takashi -# -# 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 fuga" 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" diff --git a/ryu/tests/unit/lib/test_mod/hoge/__init__.py b/ryu/tests/unit/lib/test_mod/hoge/__init__.py deleted file mode 100644 index ca8ef539..00000000 --- a/ryu/tests/unit/lib/test_mod/hoge/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. -# Copyright (C) 2013 YAMAMOTO Takashi -# -# 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/hoge/mod.py b/ryu/tests/unit/lib/test_mod/hoge/mod.py deleted file mode 100644 index 2f363d0b..00000000 --- a/ryu/tests/unit/lib/test_mod/hoge/mod.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. -# Copyright (C) 2013 YAMAMOTO Takashi -# -# 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 hoge" -- cgit v1.2.3