Codebase list ros-catkin-pkg / 06cd29c
Update upstream source from tag 'upstream/0.5.0' Update to upstream version '0.5.0' with Debian dir 9dcd1ad5d9f8719729d302e8a2aae4ff30759fb0 Jochen Sprickerhof 2 years ago
28 changed file(s) with 305 addition(s) and 88 deletion(s). Raw diff Collapse all Expand all
99 strategy:
1010 matrix:
1111 os: [ubuntu-latest, macos-latest]
12 python: [3.7, 3.8, 3.9]
12 python: ['3.7', '3.8', '3.9', '3.10']
1313 include:
1414 - os: ubuntu-18.04
15 python: 2.7
16 - os: macos-latest
17 python: 2.7
15 python: '2.7'
1816 - os: ubuntu-18.04
19 python: 3.6
17 python: '3.6'
2018 name: catkin_pkg tests
2119 runs-on: ${{matrix.os}}
2220
2321 steps:
2422 - uses: actions/checkout@v2
2523 - name: Set up Python ${{matrix.python}}
26 uses: actions/setup-python@v1
24 uses: actions/setup-python@v2
2725 with:
2826 python-version: ${{matrix.python}}
2927 - name: Install dependencies
3028 run: |
31 python -m pip install argparse coverage docutils mock nose pyparsing python-dateutil
32 python -m pip install flake8 flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-import-order flake8-quotes
29 python -m pip install -U -e .[test]
3330 - name: Run tests
3431 run: |
35 python -m nose -s --tests test
32 python -m pytest -s test
+0
-21
.travis.yml less more
0 language: python
1 os: linux
2 dist: xenial
3 python:
4 - "2.7"
5 - "3.4"
6 - "3.5"
7 - "3.6"
8 - "3.7"
9 - "3.8"
10 # command to install dependencies
11 install:
12 # newer versions of docutils dropped support for Python 3.4
13 - if [ $TRAVIS_PYTHON_VERSION == "3.4" ]; then pip install docutils==0.15.2; else pip install docutils; fi
14 - pip install nose coverage argparse python-dateutil pyparsing
15 - pip install flake8 flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-import-order flake8-quotes
16 # command to run tests
17 script:
18 - nosetests -s --tests test
19 notifications:
20 email: false
0 0.5.0 (2022-05-10)
1 ==================
2
3 - Remove references to Travis CI. `#314 <https://github.com/ros-infrastructure/catkin_pkg/pull/314>`_
4 - Drop python 2.7 on macOS. `#318 <https://github.com/ros-infrastructure/catkin_pkg/pull/318>`_
5 - Update release suites. `#317 <https://github.com/ros-infrastructure/catkin_pkg/pull/317>`_
6 - Use unittest.mock where possible. `#321 <https://github.com/ros-infrastructure/catkin_pkg/pull/321>`_
7 - Declare test dependencies in extras_require.test. `#323 <https://github.com/ros-infrastructure/catkin_pkg/pull/323>`_
8 - Drop support for Python < 2.7 (2.7 itself is still supported). `#322 <https://github.com/ros-infrastructure/catkin_pkg/pull/322>`_
9 - Run tests with pytest instead of nose. `#324 <https://github.com/ros-infrastructure/catkin_pkg/pull/324>`_
10 - Enable Python 3.10 tests, bump actions/setup-python. `#325 <https://github.com/ros-infrastructure/catkin_pkg/pull/325>`_
11 - Mark linter test and declare cov/junit module name. `#327 <https://github.com/ros-infrastructure/catkin_pkg/pull/327>`_
12 - Add plaintext_description field to Package. `#305 <https://github.com/ros-infrastructure/catkin_pkg/pull/305>`_
13 - Use only first line of plaintext description in distutils setup generation. `#326 <https://github.com/ros-infrastructure/catkin_pkg/pull/326>`_
14 - Update catkin_prepare_release to support setup.py files in ament_python packages. `#331 <https://github.com/ros-infrastructure/catkin_pkg/pull/331>`_
15 - This pull requests introduces an API change!
16 ``catkin_pkg.package_version.update_packages`` now takes the full dict of package Paths: Package objects instead of just the paths.
17 - Make filenames to be used as ignore markers configurable. `#307 <https://github.com/ros-infrastructure/catkin_pkg/pull/307>`_
18 - Fix catkin_package_version after API change. `#333 <https://github.com/ros-infrastructure/catkin_pkg/pull/333>`_
19
20 Contributors
21 ------------
22
23 - Jan Strohbeck
24 - Scott K Logan
25 - Steven! Ragnarök
26 - Tomáš Hrnčiar
27 - William Woodall
2626 echo "running ${NAME} tests"
2727
2828 test: testsetup
29 cd test && nosetests && nosetests3
29 cd test && pytest && pytest-3
1515 Continuous Integration
1616 ----------------------
1717
18 +--------------------------------------------------------------------------+--------------------------------------------------------------------+
19 | `Build Status <https://travis-ci.org/ros-infrastructure/catkin_pkg>`_. | .. image:: https://travis-ci.org/ros-infrastructure/catkin_pkg.png |
20 +--------------------------------------------------------------------------+--------------------------------------------------------------------+
18 .. image:: https://github.com/ros-infrastructure/catkin_pkg/actions/workflows/ci.yaml/badge.svg?branch=master&event=push
19 :target: https://github.com/ros-infrastructure/catkin_pkg/actions/workflows/ci.yaml?query=branch%3Amaster+event%3Apush
0 [tool:pytest]
1 junit_suite_name = catkin_pkg
2 markers =
3 flake8
4 linter
5
6 [coverage:run]
7 source = catkin_pkg
00 #!/usr/bin/env python
11
22 import os
3 import sys
43
54 from setuptools import setup
65
7 install_requires = [
8 'docutils',
9 'python-dateutil',
10 'pyparsing',
11 ]
12
13 # argparse is part of the standard library since Python 2.7
14 if sys.version_info[0] == 2 and sys.version_info[1] < 7:
15 install_requires.append('argparse')
166
177 kwargs = {
188 'name': 'catkin_pkg',
199 # same version as in:
2010 # - src/catkin_pkg/__init__.py
2111 # - stdeb.cfg
22 'version': '0.4.24',
12 'version': '0.5.0',
2313 'packages': ['catkin_pkg', 'catkin_pkg.cli'],
2414 'package_dir': {'': 'src'},
2515 'package_data': {'catkin_pkg': ['templates/*.in']},
4434 'description': 'catkin package library',
4535 'long_description': 'Library for retrieving information about catkin packages.',
4636 'license': 'BSD',
47 'install_requires': install_requires,
37 'install_requires': [
38 'docutils',
39 'python-dateutil',
40 'pyparsing',
41 'setuptools',
42 ],
43 'extras_require': {
44 'test': [
45 'flake8',
46 'flake8-blind-except',
47 'flake8-builtins',
48 'flake8-class-newline',
49 'flake8-comprehensions',
50 'flake8-deprecated',
51 'flake8-docstrings',
52 'flake8-import-order',
53 'flake8-quotes',
54 "mock; python_version < '3.3'",
55 'pytest',
56 ]},
4857 }
4958 if 'SKIP_PYTHON_MODULES' in os.environ:
5059 kwargs['packages'] = []
3434 # same version as in:
3535 # - setup.py
3636 # - stdeb.cfg
37 __version__ = '0.4.24'
37 __version__ = '0.5.0'
3232 else:
3333 # bump the version number
3434 new_version = bump_version(version, args.bump)
35 update_versions(packages.keys(), new_version)
35 update_versions(packages, new_version)
3636 print('%s -> %s' % (version, new_version))
3737 except Exception as e: # noqa: B902
3838 sys.exit(str(e))
132132 def commit_files(base_path, vcs_type, packages, packages_with_changelogs, message, dry_run=False):
133133 cmd = [_find_executable(vcs_type), 'commit', '-m', message]
134134 cmd += [os.path.join(p, PACKAGE_MANIFEST_FILENAME) for p in packages.keys()]
135 cmd += [s for s in [os.path.join(p, 'setup.py') for p in packages.keys()] if os.path.exists(s)]
135136 cmd += [path for path, _, _ in packages_with_changelogs.values()]
136137 if not dry_run:
137138 try:
265266 # complain about packages with upper case character since they won't be releasable with bloom
266267 unsupported_pkg_names = []
267268 invalid_pkg_names = []
269 valid_build_types = ['catkin', 'ament_cmake', 'ament_python']
268270 for package in packages.values():
269 build_types = [export.content for export in package.exports if export.tagname == 'build_type']
270 build_type = build_types[0] if build_types else 'catkin'
271 if build_type not in ('catkin', 'ament_cmake'):
271 build_type = package.get_build_type()
272 if build_type not in valid_build_types:
272273 unsupported_pkg_names.append(package.name)
273274 if package.name != package.name.lower():
274275 invalid_pkg_names.append(package.name)
275276 if unsupported_pkg_names:
276277 print(
277278 fmt(
278 "@{yf}Warning: the following package are not of build_type catkin or ament_cmake and may require manual steps to release': %s" %
279 "@{yf}Warning: the following package are not of build_type %s and may require manual steps to release': %s" %
280 str(valid_build_types),
279281 ', '.join([('@{boldon}%s@{boldoff}' % p) for p in sorted(unsupported_pkg_names)])
280282 ), file=sys.stderr)
281283 if not args.non_interactive and not prompt_continue('Continue anyway', default=False):
303305 raise RuntimeError(fmt(
304306 "@{rf}Invalid metapackage at path '@{boldon}%s@{boldoff}':\n %s\n\nSee requirements for metapackages: %s" %
305307 (os.path.abspath(pkg_path), str(e), metapackage.DEFINITION_URL)))
308 # verify that the setup.py files don't have modifications pending
309 setup_py_path = os.path.join(pkg_path, 'setup.py')
310 if os.path.exists(setup_py_path) and has_changes(base_path, setup_py_path, vcs_type):
311 local_modifications.append(setup_py_path)
306312
307313 # fetch current version and verify that all packages have same version number
308314 old_version = verify_equal_package_versions(packages.values())
379385 (new_version, ', '.join([('@{boldon}%s@{boldoff}' % p) for p in sorted(missing_changelogs_but_forthcoming.keys())]))))
380386
381387 # bump version number
382 update_versions(packages.keys(), new_version)
388 update_versions(packages, new_version)
383389 print(fmt("@{gf}Bump version@{reset} of all packages from '@{bf}%s@{reset}' to '@{bf}@{boldon}%s@{boldoff}@{reset}'" % (old_version, new_version)))
384390
385391 pushed = None
5959 'version',
6060 'version_compatibility',
6161 'description',
62 'plaintext_description',
6263 'maintainers',
6364 'licenses',
6465 'urls',
623624
624625 # description
625626 pkg.description = _get_node_value(_get_node(root, 'description', filename), allow_xml=True, apply_str=False)
627 pkg.plaintext_description = re.sub(' +(\n+) +', r'\1', _get_node_text(_get_node(root, 'description', filename)), flags=re.MULTILINE)
626628
627629 # at least one maintainer, all must have email
628630 maintainers = _get_nodes(root, 'maintainer')
803805 return value
804806
805807
808 def _get_node_text(node, strip=True):
809 value = ''
810 for child in node.childNodes:
811 if child.nodeType == child.TEXT_NODE:
812 value += re.sub(r'\s+', ' ', child.data)
813 elif child.nodeType == child.ELEMENT_NODE:
814 if child.tagName == 'br':
815 value += '\n'
816 else:
817 value += _get_node_text(child, strip=False)
818 else:
819 assert 'unreachable'
820 if strip:
821 value = value.strip()
822 return value
823
824
806825 def _get_node_attr(node, attr, default=False):
807826 """:param default: False means value is required."""
808827 if node.hasAttribute(attr):
8383 return new_package_str
8484
8585
86 def _replace_setup_py_version(setup_py_str, new_version):
87 """
88 Replace the version tag in contents if there is only one instance and it is using a literal as the version.
89
90 :param str package_str: contents of setup.py
91 :param str new_version: new version number
92 :returns: new setup.py string
93 :rtype: str
94 :raises RuntimeError:
95 """
96 # try to replace contents
97 new_setup_py_str, number_of_subs = re.subn(
98 r'version=([\'"])\d+\.\d+\.\d+([\'"]),',
99 r'version=\g<1>%s\g<2>,' % new_version,
100 setup_py_str)
101 if number_of_subs == 0:
102 raise RuntimeError("Failed to find a normal version statement, e.g.: version='1.2.3',")
103 if number_of_subs != 1:
104 raise RuntimeError('Illegal number of version statements: %s' % (number_of_subs))
105 return new_setup_py_str
106
107
86108 def _check_for_version_comment(package_str, new_version):
87109 """
88110 Check if a comment is present behind the version tag and return it.
100122 return comment
101123
102124
103 def update_versions(paths, new_version):
104 """
105 Bulk replace of version: searches for package.xml files directly in given folders and replaces version tag within.
106
107 :param list paths: folder names
125 def update_versions(packages, new_version):
126 """
127 Bulk replace of version: searches for package.xml and setup.py files directly in given folders and replaces version tag within.
128
129 :param dict packages: dict from folder names to package xml objects in those folders
108130 :param str new_version: version string "int.int.int"
109131 :raises RuntimeError: if any one package.xml cannot be updated
110132 """
111133 files = {}
112 for path in paths:
134 for path, package_obj in packages.items():
135 # Update any package.xml files.
113136 package_path = os.path.join(path, 'package.xml')
114137 with open(package_path, 'r') as f:
115138 package_str = f.read()
121144 except RuntimeError as rue:
122145 raise RuntimeError('Could not bump version number in file %s: %s' % (package_path, str(rue)))
123146 files[package_path] = new_package_str
147 # Update any setup.py files.
148 setup_py_path = os.path.join(path, 'setup.py')
149 if os.path.exists(setup_py_path):
150 # Only update setup.py for ament_python packages.
151 build_type = package_obj.get_build_type()
152 if build_type == 'ament_python':
153 with open(setup_py_path, 'r') as f:
154 setup_py_str = f.read()
155 try:
156 new_setup_py_str = _replace_setup_py_version(setup_py_str, new_version)
157 except RuntimeError as exc:
158 raise RuntimeError('Could not bump version number in file %s: %s' % (setup_py_path, str(exc)))
159 files[setup_py_path] = new_setup_py_str
160
124161 # if all replacements successful, write back modified package.xml
125162 for package_path, new_package_str in files.items():
126163 with open(package_path, 'w') as f:
139176 if len(section.children) > 0 and isinstance(section.children[0], docutils.nodes.title):
140177 title = section.children[0]
141178 if title and len(title.children) > 0 and isinstance(title.children[0], docutils.nodes.Text):
142 title_text = title.children[0].rawsource
179 title_text = title.children[0].astext()
143180 if FORTHCOMING_LABEL.lower() in title_text.lower():
144181 if forthcoming_label:
145182 raise RuntimeError('Found multiple forthcoming sections')
3939 from .package import parse_package_string
4040
4141
42 def find_package_paths(basepath, exclude_paths=None, exclude_subspaces=False):
42 DEFAULT_IGNORE_MARKERS = {'AMENT_IGNORE', 'CATKIN_IGNORE', 'COLCON_IGNORE'}
43
44
45 def find_package_paths(basepath, exclude_paths=None, exclude_subspaces=False, ignore_markers=DEFAULT_IGNORE_MARKERS):
4346 """
4447 Crawls the filesystem to find package manifest files.
4548
46 When a subfolder contains either of the following files it is ignored:
49 When a subfolder contains either of the files mentioned in ``ignore_markers`` it is ignored. By default, these are:
4750 - ``AMENT_IGNORE``
4851 - ``CATKIN_IGNORE``
4952 - ``COLCON_IGNORE``
5255 :param exclude_paths: A list of paths which should not be searched, ``list``
5356 :param exclude_subspaces: The flag is subfolders containing a .catkin file should not be
5457 searched, ``bool``
58 :param ignore_markers: Names of files that indicate that a folder should be ignored, ``set``
5559 :returns: A list of relative paths containing package manifest files ``list``
5660 """
5761 paths = []
5862 real_exclude_paths = [os.path.realpath(p) for p in exclude_paths] if exclude_paths is not None else []
5963 for dirpath, dirnames, filenames in os.walk(basepath, followlinks=True):
60 if set(dirnames + filenames) & {'AMENT_IGNORE', 'CATKIN_IGNORE', 'COLCON_IGNORE'} or \
64 if set(dirnames + filenames) & ignore_markers or \
6165 os.path.realpath(dirpath) in real_exclude_paths or \
6266 (exclude_subspaces and '.catkin' in filenames):
6367 del dirnames[:]
7175 return paths
7276
7377
74 def find_packages(basepath, exclude_paths=None, exclude_subspaces=False, warnings=None):
78 def find_packages(basepath, exclude_paths=None, exclude_subspaces=False, warnings=None, ignore_markers=DEFAULT_IGNORE_MARKERS):
7579 """
7680 Crawls the filesystem to find package manifest files and parses them.
7781
7983 :param exclude_paths: A list of paths which should not be searched, ``list``
8084 :param exclude_subspaces: The flag is subfolders containing a .catkin file should not be
8185 searched, ``bool``
82 :param warnings: Print warnings if None or return them in the given list
86 :param warnings: Print warnings if None or return them in the given list, ``bool``
87 :param ignore_markers: Names of files that indicate that a folder should be ignored, ``set``
8388 :returns: A dict mapping relative paths to ``Package`` objects ``dict``
8489 :raises: :exc:RuntimeError` If multiple packages have the same name
8590 """
86 packages = find_packages_allowing_duplicates(basepath, exclude_paths=exclude_paths, exclude_subspaces=exclude_subspaces, warnings=warnings)
91 packages = find_packages_allowing_duplicates(basepath, exclude_paths=exclude_paths,
92 exclude_subspaces=exclude_subspaces, warnings=warnings,
93 ignore_markers=ignore_markers)
8794 package_paths_by_name = {}
8895 for path, package in packages.items():
8996 if package.name not in package_paths_by_name:
108115 return (path, parsed_package), warnings
109116
110117
111 def find_packages_allowing_duplicates(basepath, exclude_paths=None, exclude_subspaces=False, warnings=None):
118 def find_packages_allowing_duplicates(basepath, exclude_paths=None, exclude_subspaces=False, warnings=None, ignore_markers=DEFAULT_IGNORE_MARKERS):
112119 """
113120 Crawls the filesystem to find package manifest files and parses them.
114121
117124 :param exclude_subspaces: The flag is subfolders containing a .catkin file should not be
118125 searched, ``bool``
119126 :param warnings: Print warnings if None or return them in the given list
127 :param ignore_markers: Names of files that indicate that a folder should be ignored, ``set``
120128 :returns: A dict mapping relative paths to ``Package`` objects ``dict``
121129 """
122 package_paths = find_package_paths(basepath, exclude_paths=exclude_paths, exclude_subspaces=exclude_subspaces)
130 package_paths = find_package_paths(basepath, exclude_paths=exclude_paths, exclude_subspaces=exclude_subspaces, ignore_markers=ignore_markers)
123131
124132 xmls = {}
125133 for path in package_paths:
5656 the "url" field.
5757
5858 The "description" is taken from the eponymous tag if it does not
59 exceed 200 characters. If it does "description" contains the
60 truncated text while "description_long" contains the complete.
59 exceed 200 characters and has no newlines. If it does "description"
60 contains the truncated text while "long_description" contains the
61 complete.
6162
6263 All licenses are merged into the "license" field.
6364
9798 elif package.urls:
9899 data['url'] = package.urls[0].url
99100
100 if len(package.description) <= 200:
101 data['description'] = package.description
102 else:
103 data['description'] = package.description[:197] + '...'
104 data['long_description'] = package.description
101 description = package.plaintext_description.splitlines()[0]
102 if len(description) > 200:
103 description = description[:197] + '...'
104
105 data['description'] = description
106 if description != package.plaintext_description:
107 data['long_description'] = package.plaintext_description
105108
106109 data['license'] = ', '.join(package.licenses)
107110
22 ; catkin-pkg-modules same version as in:
33 ; - setup.py
44 ; - src/catkin_pkg/__init__.py
5 Depends: python-argparse, python-catkin-pkg-modules (>= 0.4.24), python-dateutil, python-docutils
5 Depends: python-argparse, python-catkin-pkg-modules (>= 0.5.0), python-dateutil, python-docutils
66 ; catkin-pkg-modules same version as in:
77 ; - setup.py
88 ; - src/catkin_pkg/__init__.py
9 Depends3: python3-catkin-pkg-modules (>= 0.4.24), python3-dateutil, python3-docutils
9 Depends3: python3-catkin-pkg-modules (>= 0.5.0), python3-dateutil, python3-docutils
1010 Conflicts: catkin, python3-catkin-pkg
1111 Conflicts3: catkin, python-catkin-pkg
1212 Copyright-File: LICENSE
13 Suite: xenial yakkety zesty artful bionic cosmic disco eoan jessie stretch buster
14 Suite3: xenial yakkety zesty artful bionic cosmic disco eoan focal jessie stretch buster
13 Suite: bionic cosmic disco eoan jessie stretch buster
14 Suite3: bionic cosmic disco eoan focal jammy buster bullseye
1515 Python2-Depends-Name: python
1616 X-Python3-Version: >= 3.4
1717 Setup-Env-Vars: SKIP_PYTHON_MODULES=1
2525 Replaces: python-catkin-pkg (<< 0.3.0)
2626 Replaces3: python3-catkin-pkg (<< 0.3.0)
2727 Copyright-File: LICENSE
28 Suite: xenial yakkety zesty artful bionic cosmic disco eoan jessie stretch buster
29 Suite3: xenial yakkety zesty artful bionic cosmic disco eoan focal jessie stretch buster
28 Suite: bionic cosmic disco eoan jessie stretch buster
29 Suite3: bionic cosmic disco eoan focal jammy buster bullseye
3030 Python2-Depends-Name: python
3131 X-Python3-Version: >= 3.4
3232 Setup-Env-Vars: SKIP_PYTHON_SCRIPTS=1
00 import os
11 import sys
22
3 sys.path.insert(0, os.path.join('..', 'src'))
3 sys.path.insert(0, os.path.join(
4 os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
5 'src'))
0 <?xml version="1.0"?>
1 <package>
2 <name>catkin_ignored</name>
3 <version>1.2.0</version>
4 <description>Package with a CATKIN_IGNORE file.</description>
5
6 <maintainer email="user@todo.todo">üser</maintainer>
7 <license>BSD</license>
8 <buildtool_depend>catkin</buildtool_depend>
9 </package>
0 <?xml version="1.0"?>
1 <package>
2 <name>custom_ignored</name>
3 <version>1.2.0</version>
4 <description>Package with a CUSTOM_IGNORE file.</description>
5
6 <maintainer email="user@todo.todo">üser</maintainer>
7 <license>BSD</license>
8 <buildtool_depend>catkin</buildtool_depend>
9 </package>
0 A package with an XHTML description.
1
2 This package contains several xhtml tags which are, according to REP-149, meant to be properly handled but "XML tags and multiple whitespaces" may be stripped in some situations. Another sentence in this quasi-paragraph will continue to appear on the same plaintext line because there was no <br/> tag to indicate a newline should appear in the output text.
3 This text should appear on a subsequent line.
0 <?xml version="1.0"?>
1 <?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
2 <package format="3">
3 <name>xhtml_descrption</name>
4 <version>0.1.0</version>
5 <description>
6 A package with an XHTML description.
7 <br/><br/>
8 This package contains <em>several</em> xhtml tags which
9 are, according to
10 <a href="https://www.ros.org/reps/rep-0149.html#description">REP-149</a>,
11 meant to be properly handled but &quot;XML tags and multiple
12 whitespaces&quot; may be stripped in some situations.
13 Another sentence in this quasi-paragraph will continue to appear
14 on the same plaintext line because there was no &lt;br/&gt; tag to indicate
15 a newline should appear in the output text.
16 <br/>
17 This text should appear on a subsequent line.
18 </description>
19
20 <maintainer email="user@todo.todo">üser</maintainer>
21 <license>BSD</license>
22 <buildtool_depend>catkin</buildtool_depend>
23
24 <exec_depend>foo</exec_depend>
25 <exec_depend>bar</exec_depend>
26 <exec_depend>baz</exec_depend>
27 </package>
1717 import sys
1818
1919 from flake8.api.legacy import get_style_guide
20 import pytest
2021
2122
23 @pytest.mark.flake8
24 @pytest.mark.linter
2225 def test_flake8():
2326 # Configure flake8 using the .flake8 file in the root of this repository.
2427 style_guide = get_style_guide()
1919 Person,
2020 )
2121
22 from mock import Mock
22 try:
23 from unittest.mock import Mock
24 except ImportError:
25 from mock import Mock
2326
2427 sys.stderr = sys.stdout
2528
377380 filename = os.path.join(test_data_dir, 'invalid_package.xml')
378381 self.assertRaises(InvalidPackage, parse_package, filename)
379382
383 def test_parse_package_xhtml_description(self):
384 filename = os.path.join(test_data_dir, 'xhtml_description.xml')
385 expected_plaintext_description = None
386 with open(os.path.join(test_data_dir, 'xhtml_description.txt'), 'r') as f:
387 # Strip the trailing newline from the data file.
388 expected_plaintext_description = f.read().rstrip('\n')
389 package = parse_package(filename)
390 assert package.description
391
392 assert package.plaintext_description == expected_plaintext_description
393
380394 def test_parse_package_string(self):
381395 filename = os.path.join(test_data_dir, 'valid_package.xml')
382396 xml = _get_package_xml(filename)[0]
33 import tempfile
44 import unittest
55
6 from catkin_pkg.package_version import _replace_setup_py_version
67 from catkin_pkg.package_version import _replace_version
78 from catkin_pkg.package_version import bump_version
89 from catkin_pkg.package_version import update_changelog_sections
910 from catkin_pkg.package_version import update_versions
1011
11 import mock
12 try:
13 from unittest.mock import Mock
14 except ImportError:
15 from mock import Mock
1216
1317 from .util import in_temporary_directory
1418
4145 self.assertRaises(RuntimeError, _replace_version, '<package></package>', '0.1.1')
4246 self.assertRaises(RuntimeError, _replace_version, '<package><version>0.1.1</version><version>0.1.1</version></package>', '0.1.1')
4347
48 def test_replace_setup_py_version(self):
49 self.assertEqual(
50 'version="1.0.0",',
51 _replace_setup_py_version('version="0.0.1",', '1.0.0'))
52 self.assertEqual(
53 "version='1.0.0',",
54 _replace_setup_py_version("version='0.0.1',", '1.0.0'))
55 self.assertRaises(
56 RuntimeError,
57 _replace_setup_py_version,
58 '',
59 '1.0.0')
60 self.assertRaises(
61 RuntimeError,
62 _replace_setup_py_version,
63 "version='0.1'",
64 '1.0.0')
65 self.assertRaises(
66 RuntimeError,
67 _replace_setup_py_version,
68 'version=something,',
69 '1.0.0')
70 self.assertRaises(
71 RuntimeError,
72 _replace_setup_py_version,
73 'version="0.0.1",version="0.0.1",',
74 '1.0.0')
75
4476 def test_update_versions(self):
4577 try:
4678 root_dir = tempfile.mkdtemp()
5183 with open(os.path.join(sub_dir, 'package.xml'), 'w') as fhand:
5284 fhand.write('<package><version>1.5.4</version></package>')
5385
54 update_versions([root_dir, sub_dir], '7.6.5')
86 update_versions({root_dir: Mock(), sub_dir: Mock()}, '7.6.5')
5587
5688 with open(os.path.join(root_dir, 'package.xml'), 'r') as fhand:
5789 contents = fhand.read()
68100 temp_file = os.path.join(directory, 'changelog')
69101 missing_changelogs_but_forthcoming = {}
70102 # Mock the Changelog object from catkin_pkg
71 mock_changelog = mock.Mock()
103 mock_changelog = Mock()
72104 # Create a changelog entry with a unicode char.
73105 mock_changelog.rst = ('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n'
74106 'Changelog for package fake_pkg\n'
55 from catkin_pkg.packages import find_packages_allowing_duplicates
66
77 from .util import in_temporary_directory
8
9
10 test_data_dir = os.path.join(os.path.dirname(__file__), 'data', 'ignored_packages')
811
912
1013 def _create_pkg_in_dir(path, version='0.1.0'):
5760 exception_message = str(e)
5861 assert version in exception_message
5962 assert path in exception_message
63
64
65 def test_find_no_ignored_packages():
66 result = find_packages(test_data_dir)
67 assert 'catkin_ignore' not in result
68 assert 'custom_ignore' in result
69
70
71 def test_find_no_ignored_packages_with_custom_ignore():
72 custom_result = find_packages(test_data_dir, ignore_markers={'CUSTOM_IGNORE'})
73 assert 'custom_ignore' not in custom_result
74 assert 'catkin_ignore' in custom_result
77 create_cmakelists, create_package_files, create_package_xml, PackageTemplate
88 from catkin_pkg.python_setup import generate_distutils_setup
99
10 from mock import MagicMock, Mock
10 try:
11 from unittest.mock import MagicMock, Mock
12 except ImportError:
13 from mock import MagicMock, Mock
1114
1215
1316 def u(line):
22 import sys
33 import unittest
44
5 from mock import Mock
5 try:
6 from mock import Mock
7 except ImportError:
8 from unittest.mock import Mock
69
710 try:
811 from catkin_pkg.topological_order import topological_order_packages, _PackageDecorator, \