def test_returns_none_on_error(self, m_subp): """On 'file' execution error, None should be returned.""" m_subp.side_effect = ProcessExecutionError("FILE_FAILED", exit_code=99) fname = self.tmp_path("myfile") write_file(fname, "plain text content here\n") self.assertEqual(None, identify_file(fname)) self.assertEqual( [mock.call(["file", "--brief", "--mime-type", fname])], m_subp.call_args_list)
def test_returns_none_on_error(self, m_subp): """On 'file' execution error, None should be returned.""" m_subp.side_effect = ProcessExecutionError("FILE_FAILED", exit_code=99) fname = self.tmp_path("myfile") write_file(fname, "plain text content here\n") self.assertEqual(None, identify_file(fname)) self.assertEqual( [mock.call(["file", "--brief", "--mime-type", fname])], m_subp.call_args_list)
def test_file_happy_path(self): """Test file is available and functional on plain text.""" fname = self.tmp_path("myfile") write_file(fname, "plain text content here\n") with self.allow_subp(["file"]): self.assertEqual("text/plain", identify_file(fname))
def test_file_happy_path(self): """Test file is available and functional on plain text.""" fname = self.tmp_path("myfile") write_file(fname, "plain text content here\n") with self.allow_subp(["file"]): self.assertEqual("text/plain", identify_file(fname))