Skip to content

Commit

Permalink
#342 Remove sys.stdin.isatty
Browse files Browse the repository at this point in the history
  • Loading branch information
viliambalaz committed Jan 21, 2021
1 parent 537cd1d commit f9ba598
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ def handle(self, *args, **options):
content = file.read()
except IOError as e:
raise CommandError(u'Could not open file: {}.'.format(e))
elif not sys.stdin.isatty():
content = sys.stdin.read()
else:
raise CommandError(u'Missing content source.')
content = sys.stdin.read()
if not content:
raise CommandError(u'No content given.')

attachments_finalization.delete()
AttachmentFinalization.objects.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def test_content_is_read_from_stdin_if_file_argument_is_omitted(self):
self.assertEqual(attachment_finalization.file.read(), u'Content from stdin.')

def test_file_argument_and_stdin_together_may_not_be_omitted(self):
with self.assertRaisesMessage(CommandError, u'Missing content source.'):
self.addCleanup(setattr, sys, u'stdin', sys.stdin)
sys.stdin = StringIO(u'')
with self.assertRaisesMessage(CommandError, u'No content given.'):
call_command(u'attachment_anonymization', self.attachment.pk)

def test_preferred_content_source_is_file(self):
Expand Down

0 comments on commit f9ba598

Please sign in to comment.