From e48214a679ed394079a3af684877f0acaae50866 Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Mon, 3 Apr 2023 00:20:00 +0200 Subject: [PATCH] Fix unittests after '--path' argument is validated Signed-off-by: Ondrej Nosek --- test/test_cli.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/test_cli.py b/test/test_cli.py index 84d1935..ecc279d 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -10,6 +10,7 @@ # option) any later version. See http://www.gnu.org/copyleft/gpl.html for # the full text of the license. +import argparse import io import json import os @@ -2306,13 +2307,17 @@ class TestReadReleasesFromLocalConfig(CliTestCase): self.write_file(self.package_cfg, content='[koji]\ntargets=rawhide f28 fedora epel') - @patch('os.path.exists', return_value=False) - def test_no_config_file_is_create(self, exists): + @patch('pyrpkg.utils.validate_path') + def test_no_config_file_is_create(self, validate_path): + error_msg = 'given path \'{0}\' doesn\'t exist'.format(self.cloned_repo_path) + validate_path.side_effect=argparse.ArgumentTypeError(error_msg) with patch('sys.argv', new=self.fake_cmd): - cli = self.new_cli() - - rels = cli.read_releases_from_local_config(self.active_releases) - self.assertIsNone(rels) + with patch('sys.stderr', new=six.StringIO()): + with self.assertRaises(SystemExit): # argparse.ArgumentTypeError turns to SystemExit + self.new_cli() + validate_path.assert_called_once_with(self.cloned_repo_path) + output = sys.stderr.getvalue().strip() + self.assertIn(error_msg, output) def test_no_build_target_is_configured(self): with patch('sys.argv', new=self.fake_cmd): -- 2.39.2