def test_no_changes(tmpdir, capsys): """ @type tmpdir: py._path.local.LocalPath """ tmp_file1 = tmpdir.join('foo1.txt') assert not tmp_file1.exists() pywizard_cmd(( 'apply', os.path.dirname(__file__) + '/_cli_files/test_empty.py' )) out, err = capsys.readouterr() assert 'No changes' in out
def test_create_file_ask_confirmation_do_not_create(tmpdir, monkeypatch): """ @type tmpdir: py._path.local.LocalPath """ monkeypatch.setattr(pywizard.cli, '_raw_input', lambda *args: 'n') os.chdir(str(tmpdir)) tmp_file1 = tmpdir.join('foo1.txt') assert not tmp_file1.exists() pywizard_cmd(( 'apply', os.path.dirname(__file__) + '/_cli_files/test.py' )) assert not tmp_file1.exists()
def test_create_file(tmpdir): """ @type tmpdir: py._path.local.LocalPath """ os.chdir(str(tmpdir)) tmp_file1 = tmpdir.join('foo1.txt') tmp_file2 = tmpdir.join('foo2.txt') tmp_file3 = tmpdir.join('foo3.txt') assert not tmp_file1.exists() assert not tmp_file2.exists() assert not tmp_file3.exists() pywizard_cmd(( 'apply', os.path.dirname(__file__) + '/_cli_files/test.py', '--tree', '--force' )) assert tmp_file1.exists() assert tmp_file2.exists() assert tmp_file3.exists() assert 'foo1' == tmp_file1.read() assert 'foo2' == tmp_file2.read() assert 'foo3' == tmp_file3.read() pywizard_cmd(( 'apply', os.path.dirname(__file__) + '/_cli_files/test.py', '--rollback', '--force' )) assert not tmp_file1.exists() assert not tmp_file2.exists() assert not tmp_file3.exists()