def test_pyname_not_exist(): with temp_chdir() as d: runner = CliRunner() with temp_move_path(SETTINGS_FILE, d): restore_settings() result = runner.invoke(hatch, ['shed', '-p', 'pyname']) assert result.exit_code == 0 assert 'Python path named `pyname` already does not exist.' in result.output
def test_pyname_key_not_exist(): with temp_chdir() as d: runner = CliRunner() with temp_move_path(SETTINGS_FILE, d): restore_settings() result = runner.invoke(hatch, ['init', 'ok', '-py', 'pyname']) assert result.exit_code == 1 assert 'Unable to find a Python path named `pyname`.' in result.output
def test_list_success_no_pypaths(): with temp_chdir() as d: runner = CliRunner() with temp_move_path(SETTINGS_FILE, d): restore_settings() result = runner.invoke(hatch, ['pypath', '-l']) assert result.exit_code == 0 assert ('There are no saved Python paths. Add ' 'one via `hatch pypath NAME PATH`.') in result.output
def test_success(): with temp_chdir() as d: runner = CliRunner() with temp_move_path(SETTINGS_FILE, d): restore_settings() result = runner.invoke(hatch, ['pypath', 'name', 'path']) settings = load_settings() assert settings['pypaths']['name'] == 'path' assert result.exit_code == 0 assert 'Successfully saved Python `name` located at `path`.' in result.output
def config(update_settings, restore): """Locates, updates, or restores the config file. \b $ hatch config Settings location: /home/ofek/.local/share/hatch/settings.json """ if update_settings: try: user_settings = load_settings() updated_settings = copy_default_settings() updated_settings.update(user_settings) save_settings(updated_settings) echo_success('Settings were successfully updated.') except FileNotFoundError: restore = True if restore: restore_settings() echo_success('Settings were successfully restored.') echo_success('Settings location: ' + SETTINGS_FILE)
import os from setuptools import find_packages, setup try: from hatch.settings import SETTINGS_FILE, restore_settings if not os.path.exists(SETTINGS_FILE): restore_settings() except: print( 'Failed to create config file. Try again via `hatch config --restore`.' ) with open('hatch/__init__.py', 'r') as f: for line in f: if line.startswith('__version__'): version = line.strip().split('=')[1].strip(' \'"') break else: version = '0.0.1' with open('README.rst', 'r', encoding='utf-8') as f: readme = f.read() setup( name='hatch', version=version, description='A modern project, package, and virtual env manager', long_description=readme, author='Ofek Lev', author_email='*****@*****.**',