def test_missingFile_keepGoing(self): out = self._get_stdout_as_StringIO() try: collector = Collector(OUTFILE) Assignment(sandbox.dir('issue28.json')).accept(collector.visit) self.assertTrue(len(collector.get_lines()) == 5) output = out.getvalue().strip() self.assertRegex(output, 'Not found: .*student2/file1.txt', msg=output) finally: self._restore_stdout()
import unittest import sandbox import os.path import os from io import StringIO import sys from assignment import Assignment from command import Command OUTFILE = sandbox.dir('issue28.txt') class test_issue28(unittest.TestCase): def tearDown(self): if os.path.isfile(OUTFILE): os.remove(OUTFILE) def test_missingFile_keepGoing(self): out = self._get_stdout_as_StringIO() try: collector = Collector(OUTFILE) Assignment(sandbox.dir('issue28.json')).accept(collector.visit) self.assertTrue(len(collector.get_lines()) == 5) output = out.getvalue().strip() self.assertRegex(output, 'Not found: .*student2/file1.txt', msg=output) finally: self._restore_stdout() def _get_stdout_as_StringIO(self):
def setUp(self): Command.set_default_verbosity(False) self.directory = Path(sandbox.dir('test_Command')) self.directory.mkdir() self.file_ = self.directory / 'test_simple' self.filename = str(self.file_)
def test_each(self): the_assignment = Assignment(sandbox.dir("assignment1.json")) the_assignment.accept(self.collector.visit) self.assertPathsExist()
def test_each(self): the_assignment = Assignment(sandbox.dir('assignment1.json')) the_assignment.accept(self.collector.visit) self.assertPathsExist()
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA import unittest import json import os.path import os import sandbox CONFIG_FILENAME = sandbox.dir('assignment1.json') class test_Json(unittest.TestCase): def test_canLoadJsonFile(self): config_string = '' with open(CONFIG_FILENAME) as f: config_string = f.read() config = json.loads(config_string) self.assertTrue('directory' in config) self.assertTrue('files' in config) self.assertTrue(isinstance(config['directory'], str)) self.assertTrue(isinstance(config['files'], list)) self.assertTrue(all([isinstance(x, str) for x in config['files']]))
import unittest import sandbox import os.path import os from io import StringIO import sys from assignment import Assignment from command import Command OUTFILE = sandbox.dir('issue28.txt') class test_issue28(unittest.TestCase): def tearDown(self): if os.path.isfile(OUTFILE): os.remove(OUTFILE) def test_missingFile_keepGoing(self): out = self._get_stdout_as_StringIO() try: collector = Collector(OUTFILE) Assignment(sandbox.dir('issue28.json')).accept(collector.visit) self.assertTrue(len(collector.get_lines()) == 5) output = out.getvalue().strip() self.assertRegex(output, 'Not found: .*student2/file1.txt', msg=output) finally: self._restore_stdout()
# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA import unittest import json import os.path import os import sandbox CONFIG_FILENAME = sandbox.dir('assignment1.json') class test_Json(unittest.TestCase): def test_canLoadJsonFile(self): config_string = '' with open(CONFIG_FILENAME) as f: config_string = f.read() config = json.loads(config_string) self.assertTrue('directory' in config) self.assertTrue('files' in config) self.assertTrue(isinstance(config['directory'], str)) self.assertTrue(isinstance(config['files'], list)) self.assertTrue(all([isinstance(x, str) for x in config['files']]))