Skip to content

Commit

Permalink
Merge pull request #732 from SampleText2k77/fix-tests
Browse files Browse the repository at this point in the history
fix #715: Get tests running + remove obsolete Argparse tests
  • Loading branch information
audreyfeldroy committed Apr 6, 2024
2 parents 1d36a16 + c7bcfdf commit 61d8c33
Showing 1 changed file with 5 additions and 35 deletions.
40 changes: 5 additions & 35 deletions tests/test_bake_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def test_year_compute_in_license_file(cookies):

def project_info(result):
"""Get toplevel dir, project_slug, and project dir from baked cookies"""
assert result.exception is None
assert result.project.isdir()

project_path = str(result.project)
project_slug = os.path.split(project_path)[-1]
project_dir = os.path.join(project_path, project_slug)
Expand Down Expand Up @@ -269,19 +272,7 @@ def test_bake_with_no_console_script(cookies):


def test_bake_with_console_script_files(cookies):
context = {'command_line_interface': 'click'}
result = cookies.bake(extra_context=context)
project_path, project_slug, project_dir = project_info(result)
found_project_files = os.listdir(project_dir)
assert "cli.py" in found_project_files

setup_path = os.path.join(project_path, 'setup.py')
with open(setup_path, 'r') as setup_file:
assert 'entry_points' in setup_file.read()


def test_bake_with_argparse_console_script_files(cookies):
context = {'command_line_interface': 'argparse'}
context = {'command_line_interface': 'Click'}
result = cookies.bake(extra_context=context)
project_path, project_slug, project_dir = project_info(result)
found_project_files = os.listdir(project_dir)
Expand All @@ -293,28 +284,7 @@ def test_bake_with_argparse_console_script_files(cookies):


def test_bake_with_console_script_cli(cookies):
context = {'command_line_interface': 'click'}
result = cookies.bake(extra_context=context)
project_path, project_slug, project_dir = project_info(result)
module_path = os.path.join(project_dir, 'cli.py')
module_name = '.'.join([project_slug, 'cli'])
spec = importlib.util.spec_from_file_location(module_name, module_path)
cli = importlib.util.module_from_spec(spec)
spec.loader.exec_module(cli)
runner = CliRunner()
noarg_result = runner.invoke(cli.main)
assert noarg_result.exit_code == 0
noarg_output = ' '.join([
'Replace this message by putting your code into',
project_slug])
assert noarg_output in noarg_result.output
help_result = runner.invoke(cli.main, ['--help'])
assert help_result.exit_code == 0
assert 'Show this message' in help_result.output


def test_bake_with_argparse_console_script_cli(cookies):
context = {'command_line_interface': 'argparse'}
context = {'command_line_interface': 'Click'}
result = cookies.bake(extra_context=context)
project_path, project_slug, project_dir = project_info(result)
module_path = os.path.join(project_dir, 'cli.py')
Expand Down

0 comments on commit 61d8c33

Please sign in to comment.