diff options
-rw-r--r-- | lib/git/blob.py | 2 | ||||
-rw-r--r-- | test/fixtures/cat_file_blob_nl | 1 | ||||
-rw-r--r-- | test/git/test_blob.py | 12 | ||||
-rw-r--r-- | test/git/test_repo.py | 2 |
4 files changed, 13 insertions, 4 deletions
diff --git a/lib/git/blob.py b/lib/git/blob.py index a6768afb..fd83fe1d 100644 --- a/lib/git/blob.py +++ b/lib/git/blob.py @@ -57,7 +57,7 @@ class Blob(object): Returns str """ - self.data_stored = self.data_stored or self.repo.git.cat_file(self.id, **{'p': True}) + self.data_stored = self.data_stored or self.repo.git.cat_file(self.id, **{'p': True, 'with_raw_output': True}) return self.data_stored @property diff --git a/test/fixtures/cat_file_blob_nl b/test/fixtures/cat_file_blob_nl new file mode 100644 index 00000000..802992c4 --- /dev/null +++ b/test/fixtures/cat_file_blob_nl @@ -0,0 +1 @@ +Hello world diff --git a/test/git/test_blob.py b/test/git/test_blob.py index 68afdbd8..c4d8036c 100644 --- a/test/git/test_blob.py +++ b/test/git/test_blob.py @@ -18,7 +18,15 @@ class TestBlob(object): blob = Blob(self.repo, **{'id': 'abc'}) assert_equal("Hello world", blob.data) assert_true(git.called) - assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True})) + assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True})) + + @patch(Git, '_call_process') + def test_should_return_blob_contents_with_newline(self, git): + git.return_value = fixture('cat_file_blob_nl') + blob = Blob(self.repo, **{'id': 'abc'}) + assert_equal("Hello world\n", blob.data) + assert_true(git.called) + assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True})) @patch(Git, '_call_process') def test_should_cache_data(self, git): @@ -28,7 +36,7 @@ class TestBlob(object): blob.data assert_true(git.called) assert_equal(git.call_count, 1) - assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True})) + assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True})) @patch(Git, '_call_process') def test_should_return_file_size(self, git): diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 21b43a88..ea3032c1 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -107,7 +107,7 @@ class TestRepo(object): assert_equal("Hello world", blob.data) assert_true(git.called) - assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True})) + assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True})) @patch(Repo, '__init__') @patch(Git, '_call_process') |