def test_anonymous_reference_option(self): sys.argv = [ sys.argv[0], '--anonymous-references', '--dry-run', test_md] with patch(_builtin + '.print') as m: main() self.assertIn("`A link to GitHub <http://github.com/>`__", m.call_args[0][0])
def test_write_file(self): sys.argv = [sys.argv[0], test_md] target_file = path.join(curdir, 'test.rst') os.remove(target_file) self.assertFalse(path.exists(target_file)) main() self.assertTrue(path.exists(target_file))
def test_disable_inline_math(self): sys.argv = [ sys.argv[0], '--disable-inline-math', '--dry-run', test_md] with patch(_builtin + '.print') as m: main() self.assertIn('``$E = mc^2$``', m.call_args[0][0]) self.assertNotIn(':math:', m.call_args[0][0])
def test_underscore_option(self): sys.argv = [ sys.argv[0], '--no-underscore-emphasis', '--dry-run', test_md] with patch(_builtin + '.print') as m: main() self.assertIn('__content__', m.call_args[0][0]) self.assertNotIn('**content**', m.call_args[0][0])
def test_anonymous_reference_option(self): sys.argv = [ sys.argv[0], '--anonymous-references', '--dry-run', test_md ] with patch(_builtin + '.print') as m: main() self.assertIn("`A link to GitHub <http://github.com/>`__", m.call_args[0][0])
def test_dryrun(self): sys.argv = [sys.argv[0], '--dry-run', test_md] target_file = path.join(curdir, 'test.rst') with open(target_file) as f: rst = f.read() os.remove(target_file) self.assertFalse(path.exists(target_file)) with patch(_builtin + '.print') as m: main() self.assertFalse(path.exists(target_file)) m.assert_called_once_with(rst)
def test_overwrite_file(self): sys.argv = [sys.argv[0], test_md] target_file = path.join(curdir, 'test.rst') with open(target_file, 'w') as f: f.write('test') with open(target_file) as f: first_line = f.readline() self.assertIn('test', first_line) with patch(_builtin + '.input', return_value='y'): main() self.assertTrue(path.exists(target_file)) with open(target_file) as f: first_line = f.readline() self.assertNotIn('test', first_line)
def test_overwrite_option(self): sys.argv = [sys.argv[0], '--overwrite', test_md] target_file = path.join(curdir, 'test.rst') with open(target_file, 'w') as f: f.write('test') with open(target_file) as f: first_line = f.readline() self.assertIn('test', first_line) with patch(_builtin + '.input', return_value='y') as m_input: with patch(_builtin + '.print') as m_print: main() self.assertTrue(path.exists(target_file)) self.assertFalse(m_input.called) self.assertFalse(m_print.called) with open(target_file) as f: first_line = f.readline() self.assertNotIn('test', first_line)
def test_disable_inline_math(self): sys.argv = [sys.argv[0], '--disable-inline-math', '--dry-run', test_md] with patch(_builtin + '.print') as m: main() self.assertIn('``$E = mc^2$``', m.call_args[0][0]) self.assertNotIn(':math:', m.call_args[0][0])