From 901b9c5608c64557fdb2dba0041f1cc57b60f34a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2020 14:12:43 +0100 Subject: [PATCH 1/9] Bump black from 19.10b0 to 20.8b1 (#101) Bumps [black](https://github.com/psf/black) from 19.10b0 to 20.8b1. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/master/CHANGES.md) - [Commits](https://github.com/psf/black/commits) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 2ce7a7d..6956619 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,5 +1,5 @@ -r requirements.txt -black==19.10b0 +black==20.8b1 flake8==3.8.3 isort==5.5.4 pre-commit==2.7.1 From 2fdab2bf0765978e809f68b2a4d1f8330bd4fb18 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2020 14:26:41 +0100 Subject: [PATCH 2/9] Bump pre-commit from 2.7.1 to 2.8.2 (#107) Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.7.1 to 2.8.2. - [Release notes](https://github.com/pre-commit/pre-commit/releases) - [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md) - [Commits](https://github.com/pre-commit/pre-commit/compare/v2.7.1...v2.8.2) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 6956619..6323824 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -2,5 +2,5 @@ black==20.8b1 flake8==3.8.3 isort==5.5.4 -pre-commit==2.7.1 +pre-commit==2.8.2 tox==3.20.0 From e533ae4e3801f29558d1c34c9fe3faf70588962b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2020 14:28:22 +0100 Subject: [PATCH 3/9] Bump pytest from 6.1.0 to 6.1.2 (#108) Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.1.0 to 6.1.2. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/6.1.0...6.1.2) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 3aba098..b54b1d6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -pytest==6.1.0 +pytest==6.1.2 From 56430161894c21528acf010c74634a221094f19d Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2020 14:31:42 +0100 Subject: [PATCH 4/9] Bump isort from 5.5.4 to 5.6.4 (#109) Bumps [isort](https://github.com/pycqa/isort) from 5.5.4 to 5.6.4. - [Release notes](https://github.com/pycqa/isort/releases) - [Changelog](https://github.com/PyCQA/isort/blob/develop/CHANGELOG.md) - [Commits](https://github.com/pycqa/isort/compare/5.5.4...5.6.4) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 6323824..78f8a60 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,6 +1,6 @@ -r requirements.txt black==20.8b1 flake8==3.8.3 -isort==5.5.4 +isort==5.6.4 pre-commit==2.8.2 tox==3.20.0 From 4e79be3771e44f26f7b35d430656682a4cb2ccb5 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2020 14:31:55 +0100 Subject: [PATCH 5/9] Bump tox from 3.20.0 to 3.20.1 (#110) Bumps [tox](https://github.com/tox-dev/tox) from 3.20.0 to 3.20.1. - [Release notes](https://github.com/tox-dev/tox/releases) - [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst) - [Commits](https://github.com/tox-dev/tox/compare/3.20.0...3.20.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 78f8a60..45f46a4 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -3,4 +3,4 @@ black==20.8b1 flake8==3.8.3 isort==5.6.4 pre-commit==2.8.2 -tox==3.20.0 +tox==3.20.1 From b44dd0a13575ff9eef1e237e76b0146470afaa8b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2020 14:48:08 +0100 Subject: [PATCH 6/9] Bump flake8 from 3.8.3 to 3.8.4 (#111) Bumps [flake8](https://gitlab.com/pycqa/flake8) from 3.8.3 to 3.8.4. - [Release notes](https://gitlab.com/pycqa/flake8/tags) - [Commits](https://gitlab.com/pycqa/flake8/compare/3.8.3...3.8.4) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 45f46a4..9c1f004 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,6 +1,6 @@ -r requirements.txt black==20.8b1 -flake8==3.8.3 +flake8==3.8.4 isort==5.6.4 pre-commit==2.8.2 tox==3.20.1 From b124be7aa9ba0c803e4e5986a8732acca0ca3bd2 Mon Sep 17 00:00:00 2001 From: Ana Paula Gomes <1899950+anapaulagomes@users.noreply.github.com> Date: Fri, 20 Nov 2020 17:36:30 +0100 Subject: [PATCH 7/9] Create FUNDING.yml --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..3dc050d --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: anapaulagomes From 8d30e9dd3e8bbb89b91f5bb7ad8984493392a871 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 3 Dec 2020 14:41:24 +0100 Subject: [PATCH 8/9] Bump pre-commit from 2.8.2 to 2.9.2 (#114) Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.8.2 to 2.9.2. - [Release notes](https://github.com/pre-commit/pre-commit/releases) - [Changelog](https://github.com/pre-commit/pre-commit/blob/master/CHANGELOG.md) - [Commits](https://github.com/pre-commit/pre-commit/compare/v2.8.2...v2.9.2) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 9c1f004..2ca65e2 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -2,5 +2,5 @@ black==20.8b1 flake8==3.8.4 isort==5.6.4 -pre-commit==2.8.2 +pre-commit==2.9.2 tox==3.20.1 From ad4c1b224515d1fb7bc6a46376ad677ccc067ff5 Mon Sep 17 00:00:00 2001 From: Paul Schroeder Date: Wed, 9 Dec 2020 17:32:49 -0700 Subject: [PATCH 9/9] Add optional parameter to point to different parent branch (#113) --- CHANGELOG.md | 4 ++++ README.rst | 2 ++ pytest_picked/modes.py | 6 +++++- pytest_picked/plugin.py | 11 ++++++++++- tests/test_modes.py | 9 +++++++++ tests/test_pytest_picked.py | 27 +++++++++++++++++++++++++++ 6 files changed, 57 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20d376f..108c7bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ - Add fixture for git user configuration - Skip "Publish to Test PyPi" workflow when there is no change on setup.py +## [0.4.5] - 2020-11-17 +### Added +- Add optional parameter, `--parent-branch`, to point to different parent branch (#113) + ## [0.4.4] - 2020-03-21 ### Fixed - Fix branch mode for renaming cases (#77) diff --git a/README.rst b/README.rst index 2e03c7b..507c306 100644 --- a/README.rst +++ b/README.rst @@ -87,6 +87,8 @@ Usage $ pytest --picked --mode=unstaged # default + $ pytest --picked --mode=branch --parent-branch=main # if your parent branch differs from "master" + Features -------- diff --git a/pytest_picked/modes.py b/pytest_picked/modes.py index 09a5322..42e07df 100644 --- a/pytest_picked/modes.py +++ b/pytest_picked/modes.py @@ -49,8 +49,12 @@ def parser(self, candidate): class Branch(Mode): + def __init__(self, test_file_convention, parent_branch="master"): + super().__init__(test_file_convention) + self.parent_branch = parent_branch + def command(self): - return ["git", "diff", "--name-status", "--relative", "master"] + return ["git", "diff", "--name-status", "--relative", self.parent_branch] def parser(self, candidate): """ diff --git a/pytest_picked/plugin.py b/pytest_picked/plugin.py index cf5a973..d86a954 100644 --- a/pytest_picked/plugin.py +++ b/pytest_picked/plugin.py @@ -27,14 +27,23 @@ def pytest_addoption(parser): required=False, help="Options: unstaged, branch", ) + group.addoption( + "--parent-branch", + action="store", + dest="parent_branch", + default="master", + required=False, + help="The main branch of your repo (master, main, trunk, etc)", + ) def _get_affected_paths(config): picked_mode = config.getoption("picked_mode") + parent_branch = config.getoption("parent_branch") test_file_convention = config._getini("python_files") # pylint: disable=W0212 modes = { - "branch": Branch(test_file_convention), + "branch": Branch(test_file_convention, parent_branch), "unstaged": Unstaged(test_file_convention), } try: diff --git a/tests/test_modes.py b/tests/test_modes.py index 79a2ae0..fd3ef7a 100644 --- a/tests/test_modes.py +++ b/tests/test_modes.py @@ -100,6 +100,15 @@ def test_should_return_command_that_list_all_changed_files(self): "master", ] + def test_should_return_command_that_list_all_changed_files_for_different_branch( + self, + ): + mode = Branch([], "main") + command = mode.command() + + assert isinstance(command, list) + assert mode.command() == ["git", "diff", "--name-status", "--relative", "main"] + @pytest.mark.parametrize( "line,expected_line", [ diff --git a/tests/test_pytest_picked.py b/tests/test_pytest_picked.py index 04502a6..2abbef2 100644 --- a/tests/test_pytest_picked.py +++ b/tests/test_pytest_picked.py @@ -245,3 +245,30 @@ def test_sth(): ) result = testdir.runpytest("--picked=first", "-v") result.stdout.re_match_lines(["test_access.py.+", "test_flows.py.+"]) + + +def test_should_accept_different_parent_branch_param(testdir, tmpdir): + with patch("pytest_picked.modes.subprocess.run") as subprocess_mock: + output = b"M test_flows.py\nA test_serializers.py\n" + subprocess_mock.return_value.stdout = output + + result = testdir.runpytest("--picked", "--mode=branch", "--parent-branch=main") + testdir.makepyfile( + ".py", + test_flows=""" + def test_sth(): + assert True + """, + test_serializers=""" + def test_sth(): + assert True + """, + ) + tmpdir.mkdir("tests") + result.stdout.fnmatch_lines( + [ + "Changed test files... 2. " + + "['test_flows.py', 'test_serializers.py']", + "Changed test folders... 0. []", + ] + )