def antiweb_process(fd, log_file): #we need to duplicate the file descriptor and reset the stdin for a childprocess #now the the parent and child process read from the same stdin sys.stdin = os.fdopen(os.dup(fd)) #need to use a file here, as string streams are not serializable but have to be used by different processes with open(log_file, "w") as logger: sys.stdout = logger main()
def test_antiweb_rst_r(self): compare_path_small_testfile = self.data_dir.get_path( "docs", "ein_rst.rst") self.test_args = ['antiweb.py', "-r", self.temp_dir.get_path()] with patch.object(sys, 'argv', self.test_args): self.functional("", "ein_rst_docs.rst", compare_path_small_testfile, main()) self.file_not_exist(self.temp_dir.get_path("index.rst"))
def test_xml_tags(self): compare_path_small_testfile = self.data_dir.get_path("test_xml.rst") self.test_args = ['antiweb.py', self.temp_dir.get_path("test_xml.cs")] with patch.object(sys, 'argv', self.test_args): self.functional("", "test_xml.rst", compare_path_small_testfile, main()) self.file_not_exist(self.temp_dir.get_path("index.rst"))
def test_antiweb_rst_r_i(self): compare_path_small_testfile = self.data_dir.get_path("ein_rst_docs.rst") compare_path_index = self.data_dir.get_path("index.rst") self.test_args = ['antiweb.py', '-i', "-r", self.temp_dir.get_path()] with patch.object(sys, 'argv', self.test_args): self.functional("", "ein_rst_docs.rst", compare_path_small_testfile, main()) self.functional("", "index.rst", compare_path_index, os.path.isfile(self.temp_dir.get_path("index.rst")))
def test_antiweb_o_file(self): output_file_name = "small_testfile.rst" compare_path_small_testfile = self.data_dir.get_path(output_file_name) self.test_args = ['antiweb.py', "-o", self.temp_dir.get_path(output_file_name), self.destination_path] with patch.object(sys, 'argv', self.test_args): self.functional("", output_file_name, compare_path_small_testfile, main())
def test_antiweb_r_no_argument(self): previ_dir = os.getcwd() os.chdir(self.temp_dir.get_relative_path()) compare_path_small_testfile = self.data_dir.get_path("docs","small_testfile.rst") self.test_args = ['antiweb.py', "-r"] with patch.object(sys, 'argv', self.test_args): self.functional("", "small_testfile.rst", compare_path_small_testfile, main()) os.chdir(previ_dir)
def test_antiweb_o_relative_path(self): compare_path_small_testfile = self.data_dir.get_path("small_testfile.rst") relative_path = self.temp_dir.get_relative_path(self.doc_dir) self.test_args = ['antiweb.py', "-o",relative_path, self.destination_path] with patch.object(sys, 'argv', self.test_args): self.functional("", os.path.join(self.doc_dir, "small_testfile.rst"), compare_path_small_testfile, main())
def test_antiweb_rst_r_i(self): compare_path_small_testfile = self.data_dir.get_path( "ein_rst_docs.rst") compare_path_index = self.data_dir.get_path("index.rst") self.test_args = ['antiweb.py', '-i', "-r", self.temp_dir.get_path()] with patch.object(sys, 'argv', self.test_args): self.functional("", "ein_rst_docs.rst", compare_path_small_testfile, main()) self.functional( "", "index.rst", compare_path_index, os.path.isfile(self.temp_dir.get_path("index.rst")))
def test_antiweb(self): compare_path_small_testfile = self.data_dir.get_path( "small_testfile.rst") self.test_args = [ 'antiweb.py', self.temp_dir.get_path("small_testfile.py") ] with patch.object(sys, 'argv', self.test_args): self.functional("", "small_testfile.rst", compare_path_small_testfile, main()) self.file_not_exist(self.temp_dir.get_path("index.rst"))
def test_antiweb_relative_path(self): compare_path_small_testfile = self.data_dir.get_path("small_testfile.rst") self.test_args = ['antiweb.py', self.temp_dir.get_relative_path(self.destination_path)] with patch.object(sys, 'argv', self.test_args): self.functional(self.source_dir, "small_testfile.rst", compare_path_small_testfile, main())
def test_antiweb_rst_relative_path(self): compare_path_small_testfile = self.data_dir.get_path("ein_rst_docs.rst") self.test_args = ['antiweb.py', self.temp_dir.get_relative_path("ein_rst.rst")] with patch.object(sys, 'argv', self.test_args): self.functional("", "ein_rst_docs.rst", compare_path_small_testfile, main())
def test_antiweb_r_absolute(self): compare_path_small_testfile = self.data_dir.get_path("small_testfile.rst") self.test_args = ['antiweb.py',"-r", self.temp_dir.get_path()] with patch.object(sys, 'argv', self.test_args): self.functional("", "small_testfile.rst", compare_path_small_testfile, main())
def test_antiweb_r_o_absolute_path(self): compare_path_small_testfile = self.data_dir.get_path( "docs", "small_testfile.rst") self.test_args = ['antiweb.py',"-o", self.doc_dir, "-r", self.temp_dir.get_path()] with patch.object(sys, 'argv', self.test_args): self.functional(self.doc_dir, "small_testfile.rst", compare_path_small_testfile, main()) self.file_not_exist(self.temp_dir.get_path(self.doc_dir, "index.rst"))
def test_antiweb_i_o(self): compare_path_small_testfile = self.data_dir.get_path("small_testfile.rst") compare_path_index = self.data_dir.get_path("index.rst") self.test_args = ['antiweb.py', '-i', "-o", self.doc_dir, self.temp_dir.get_path("small_testfile.py")] with patch.object(sys, 'argv', self.test_args): self.functional("", os.path.join(self.doc_dir, "small_testfile.rst"), compare_path_small_testfile, main()) self.functional("", "index.rst", compare_path_index, os.path.isfile(self.temp_dir.get_path("index.rst")))
def test_xml(self): compare_path = self.data_dir.get_path("test_xml.rst") self.test_args = ['antiweb.py', self.destination_path] with patch.object(sys, 'argv', self.test_args): self.functional("", "test_xml.rst", compare_path, main())
def test_simple(self): compare_path_small_testfile = self.data_dir.get_path("test_simple.rst") self.test_args = ['antiweb.py', self.temp_dir.get_path("test_simple.cs")] with patch.object(sys, 'argv', self.test_args): self.functional("", "test_simple.rst", compare_path_small_testfile, main())
def test_antiweb_o_directory(self): compare_path_small_testfile = self.data_dir.get_path("small_testfile.rst") self.test_args = ['antiweb.py', "-o", self.doc_dir, self.temp_dir.get_path("small_testfile.py")] with patch.object(sys, 'argv', self.test_args): self.functional("", os.path.join(self.doc_dir, "small_testfile.rst"), compare_path_small_testfile, main()) self.file_not_exist(self.temp_dir.get_path("index.rst"))
def test_antiweb_rst_o(self): compare_path_small_testfile = self.data_dir.get_path("ein_rst_docs.rst") self.test_args = ['antiweb.py', "-o", self.temp_dir.get_path(self.doc_dir), self.temp_dir.get_path("ein_rst.rst")] with patch.object(sys, 'argv', self.test_args): self.functional("", os.path.join(self.doc_dir, "ein_rst_docs.rst"), compare_path_small_testfile, main())