Skip to content

Commit

Permalink
fixed test files
Browse files Browse the repository at this point in the history
  • Loading branch information
atiderko committed Aug 11, 2023
1 parent ffff604 commit 329a475
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

from fkie_multimaster_pylib import formats

PKG = 'fkie_multimaster_msgs'
PKG = 'fkie_multimaster_pylib'


class TestFormatsLib(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import fkie_multimaster_pylib.system.host as host

PKG = 'fkie_multimaster_msgs'
PKG = 'fkie_multimaster_pylib'


class TestHost(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from fkie_multimaster_pylib import ros_pkg
from fkie_multimaster_pylib.launch import xml

PKG = 'fkie_multimaster_msgs'
PKG = 'fkie_multimaster_pylib'


class TestLaunchXmlLib(unittest.TestCase):
Expand Down Expand Up @@ -66,7 +66,7 @@ def test_includefile_repr(self):
inc_file_str, '%s' % inc_file))

def test_interpret_path(self):
text_path = "$(find fkie_multimaster_msgs)/%s/include_dummy.launch" % self.res_dir
text_path = f"$(find {PKG})/{self.res_dir}/include_dummy.launch"
path = xml.interpret_path(text_path)
self.assertEqual(self.test_include_file, path, "wrong interpreted path, expected: %s, got: %s" % (
self.test_include_file, path))
Expand All @@ -75,19 +75,19 @@ def test_interpret_path(self):
exp_path = os.path.join(self.pkg_path, text_path)
self.assertEqual(
exp_path, path, "wrong interpreted relative path, expected: %s, got: %s" % (exp_path, path))
text_path = "pkg://fkie_multimaster_msgs/%s/include_dummy.launch" % self.res_dir
text_path = f"pkg://{PKG}/{self.res_dir}/include_dummy.launch"
path = xml.interpret_path(text_path, self.pkg_path)
self.assertEqual(self.test_include_file, path,
"wrong interpreted pkg:// path, expected: %s, got: %s" % (self.test_include_file, path))
text_path = "package://fkie_multimaster_msgs/%s/include_dummy.launch" % self.res_dir
text_path = f"package://{PKG}/{self.res_dir}/include_dummy.launch"
path = xml.interpret_path(text_path, self.pkg_path)
self.assertEqual(self.test_include_file, path,
"wrong interpreted package:// path, expected: %s, got: %s" % (self.test_include_file, path))
text_path = "file://fkie_multimaster_msgs/tests/test_launch/include_dummy.launch"
text_path = f"file://{PKG}/tests/test_launch/include_dummy.launch"
path = xml.interpret_path(text_path, self.pkg_path)
self.assertEqual(self.test_include_file, path,
"wrong interpreted file:// path, expected: %s, got: %s" % (self.test_include_file, path))
text_path = "pkg://fkie_multimaster_msgs///include_dummy.launch"
text_path = f"pkg://{PKG}///include_dummy.launch"
path = xml.interpret_path(text_path, self.pkg_path)
self.assertEqual(self.test_include_file, path,
"wrong interpreted path with replace the subdirectory by `///`, expected: %s, got: %s" % (self.test_include_file, path))
Expand All @@ -96,17 +96,16 @@ def test_interpret_path(self):
self.assertRaises(rospkg.ResourceNotFound, xml.interpret_path, text_path,
"No rospkg.ResourceNotFound raises on invalid pacakge name")

text_path = "some other --args here '$(find fkie_multimaster_msgs)/%s/include_dummy.launch'" % self.res_dir
text_path = f"some other --args here '$(find {PKG})/{self.res_dir}/include_dummy.launch'"
path = xml.interpret_path(text_path)
self.assertEqual(self.test_include_file, path, "wrong interpreted path, expected: %s, got: %s" % (
self.test_include_file, path))

def test_replace_paths(self):
text_path = "$(find fkie_multimaster_msgs)/fkie_multimaster_msgs/tests/test_launch/include_dummy.launch, $(find fkie_node_manager_daemon)/launch/demo_bar.launch"
text_path = f"$(find {PKG})/{PKG}/tests/test_launch/include_dummy.launch, $(find fkie_node_manager_daemon)/launch/demo_bar.launch"
path = xml.replace_paths(text_path)
nm_path = os.path.dirname(self.pkg_path.rstrip(os.path.sep))
path_exp = "%s/fkie_multimaster_msgs/fkie_multimaster_msgs/tests/test_launch/include_dummy.launch, %s/launch/demo_bar.launch" % (
nm_path, self.nmgr_path.rstrip(os.path.sep))
path_exp = f"{nm_path}]/{PKG}/{PKG}/tests/test_launch/include_dummy.launch, {self.nmgr_path.rstrip(os.path.sep)}/launch/demo_bar.launch"
self.assertEqual(
path_exp, path, "wrong replace_paths, expected: %s, got: %s" % (path_exp, path))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from fkie_multimaster_pylib import ros_pkg
from fkie_multimaster_pylib.launch import xml

PKG = 'fkie_multimaster_msgs'
PKG = 'fkie_multimaster_pylib'


class TestRosPkgLib(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import fkie_multimaster_pylib.system.screen as screen
from fkie_multimaster_pylib.system.screen import SCREEN_SLASH_SEP

PKG = 'fkie_multimaster_msgs'
PKG = 'fkie_multimaster_pylib'
TEST_NODE_NAME = f'{SCREEN_SLASH_SEP}test{SCREEN_SLASH_SEP}node'


Expand Down

0 comments on commit 329a475

Please sign in to comment.