diff --git a/pur/__init__.py b/pur/__init__.py index b45d6fa..ec473fd 100644 --- a/pur/__init__.py +++ b/pur/__init__.py @@ -279,6 +279,7 @@ def _update_requirements(obuffer, updates, input_file=None, spec_ver, latest_ver) obuffer.write(new_line) + obuffer.write('\n') if new_line != line: msg = 'Updated {package}: {old} -> {new}'.format( @@ -308,17 +309,17 @@ def _update_requirements(obuffer, updates, input_file=None, elif not dry_run_changed: obuffer.write(line) + obuffer.write('\n') + except StopUpdating: stop = True if not dry_run_changed: obuffer.write(line) + obuffer.write('\n') elif not output_buffer or not requirements_line(line, req): if not dry_run_changed: obuffer.write(line) - - if not output_buffer or not requirements_line(line, req): - if not dry_run_changed: obuffer.write('\n') if dry_run and echo: diff --git a/tests/samples/results/test_dry_run_changed b/tests/samples/results/test_dry_run_changed index 335836f..627b543 100644 --- a/tests/samples/results/test_dry_run_changed +++ b/tests/samples/results/test_dry_run_changed @@ -1 +1,4 @@ flask==0.10.1 +Alembic==0.10.1 +sqlalchemy==0.10.1 + diff --git a/tests/test_pur.py b/tests/test_pur.py index a627b34..044718a 100644 --- a/tests/test_pur.py +++ b/tests/test_pur.py @@ -923,7 +923,7 @@ def test_dry_run_invalid_package(self): self.assertEqual(open(tmpfile).read(), open(requirements).read()) def test_dry_run_changed(self): - requirements = 'tests/samples/requirements.txt' + requirements = 'tests/samples/requirements-multiple.txt' tempdir = tempfile.mkdtemp() tmpfile = os.path.join(tempdir, 'requirements.txt') shutil.copy(requirements, tmpfile) @@ -938,8 +938,7 @@ def test_dry_run_changed(self): result = self.runner.invoke(pur, args) self.assertIsNone(result.exception) - expected_output = '==> ' + tmpfile + ' <==\n' + \ - open('tests/samples/results/test_dry_run_changed').read() + expected_output = '==> ' + tmpfile + ' <==\n' + open('tests/samples/results/test_dry_run_changed').read() self.assertEqual(u(result.output), u(expected_output)) self.assertEqual(result.exit_code, 0) self.assertEqual(open(tmpfile).read(), open(requirements).read())