def add_known_hosts(exc_info): known_hosts = self._dir('ssh', 'known_hosts') if os.path.exists(known_hosts): content.attach_file(self, known_hosts) else: self.addDetail('known_hosts', content.text_content('Not found'))
def test_simple(self): class SomeTest(TestCase): def test_foo(self): pass test = SomeTest('test_foo') data = 'some data' path = self.make_file(data) my_content = text_content(data) attach_file(test, path, name='foo') self.assertEqual({'foo': my_content}, test.getDetails())
def test_simple(self): class SomeTest(TestCase): def test_foo(self): pass test = SomeTest("test_foo") data = "some data" path = self.make_file(data) my_content = text_content(data) attach_file(test, path, name="foo") self.assertEqual({"foo": my_content}, test.getDetails())
def test_optional_name(self): # If no name is provided, attach_file just uses the base name of the # file. class SomeTest(TestCase): def test_foo(self): pass test = SomeTest('test_foo') path = self.make_file('some data') base_path = os.path.basename(path) attach_file(test, path) self.assertEqual([base_path], list(test.getDetails()))
def test_eager_read_by_default(self): class SomeTest(TestCase): def test_foo(self): pass test = SomeTest('test_foo') path = self.make_file('some data') attach_file(test, path, name='foo') content = test.getDetails()['foo'] content_file = open(path, 'w') content_file.write('new data') content_file.close() self.assertEqual(''.join(content.iter_text()), 'some data')
def test_eager_read_by_default(self): class SomeTest(TestCase): def test_foo(self): pass test = SomeTest('test_foo') path = self.make_file('some data') attach_file(test, path, name='foo') content = test.getDetails()['foo'] content_file = open(path, 'w') content_file.write('new data') content_file.close() self.assertEqual(''.join(content.iter_bytes()), 'some data')
def test_lazy_read(self): class SomeTest(TestCase): def test_foo(self): pass test = SomeTest('test_foo') path = self.make_file('some data') attach_file(test, path, name='foo', buffer_now=False) content = test.getDetails()['foo'] content_file = open(path, 'w') content_file.write('new data') content_file.close() self.assertEqual(''.join(content.iter_bytes()), 'new data')
def test_lazy_read(self): class SomeTest(TestCase): def test_foo(self): pass test = SomeTest('test_foo') path = self.make_file('some data') attach_file(test, path, name='foo', buffer_now=False) content = test.getDetails()['foo'] content_file = open(path, 'w') content_file.write('new data') content_file.close() self.assertEqual(''.join(content.iter_text()), 'new data')
def test_eager_read_by_default(self): class SomeTest(TestCase): def test_foo(self): pass test = SomeTest("test_foo") path = self.make_file("some data") attach_file(test, path, name="foo") content = test.getDetails()["foo"] content_file = open(path, "w") content_file.write("new data") content_file.close() self.assertEqual("".join(content.iter_text()), "some data")
def add_logs(exc_info): for name in ['error_log', 'sshd_log', 'httpd_log']: content.attach_file(self, self._dir('site', 'logs', name))
def attach_file(exc_info): if os.path.exists(filename): content.attach_file(self, filename) else: self.addDetail(os.path.basename(filename), content.text_content('Not found'))