How to use loadTargets method in green

Best Python code snippet using green

test_djangorunner.py

Source:test_djangorunner.py Github

copy

Full Screen

1from __future__ import unicode_literals2from argparse import Namespace3try:4 from io import StringIO5except:6 from StringIO import StringIO7import sys8import unittest9try:10 from unittest.mock import MagicMock, patch11except:12 from mock import MagicMock, patch13from fetchdata import djangorunner14from fetchdata.config import mergeConfig15class TestDjangoMissing(unittest.TestCase):16 def test_importError(self):17 self.assertRaises(ImportError, djangorunner.django_missing)18class TestDjangoRunner(unittest.TestCase):19 def setUp(self):20 try:21 djangorunner.DjangoRunner()22 except ImportError:23 raise unittest.SkipTest("Django is not installed")24 saved_stdout = sys.stdout25 self.stream = StringIO()26 sys.stdout = self.stream27 self.addCleanup(setattr, sys, 'stdout', saved_stdout)28 def test_run_testsWithLabel(self):29 dr = djangorunner.DjangoRunner()30 dr.setup_test_environment = MagicMock()31 dr.setup_databases = MagicMock()32 dr.teardown_databases = MagicMock()33 dr.teardown_test_environment = MagicMock()34 dr.run_tests(('fetchdata.test.test_version',), testing=True)35 self.assertIn('OK', self.stream.getvalue())36 def test_run_testsWithoutLabel(self):37 """38 Not passing in a label causes the targets to be ['.']39 """40 dr = djangorunner.DjangoRunner()41 dr.setup_test_environment = MagicMock()42 dr.setup_databases = MagicMock()43 dr.teardown_databases = MagicMock()44 dr.teardown_test_environment = MagicMock()45 saved_loadTargets = djangorunner.loadTargets46 djangorunner.loadTargets = MagicMock()47 self.addCleanup(setattr, djangorunner, 'loadTargets', saved_loadTargets)48 dr.run_tests((), testing=True)49 djangorunner.loadTargets.assert_called_with(['.'])50 self.assertIn('No Tests Found', self.stream.getvalue())51 def test_run_testsWithBadInput(self):52 """53 Bad input causes a ValueError to be raised54 """55 dr = djangorunner.DjangoRunner()56 dr.setup_test_environment = MagicMock()57 dr.setup_databases = MagicMock()58 self.assertRaises(ValueError, dr.run_tests, None, True)59 @patch('fetchdata.djangorunner.fetchdataTestSuite')60 @patch('fetchdata.djangorunner.run')61 @patch('fetchdata.djangorunner.loadTargets')62 def test_run_noTests(self, mock_loadTargets, mock_run, mock_fetchdataTestSuite):63 """64 If no tests are found, we create an empty test suite and run it.65 """66 dr = djangorunner.DjangoRunner()67 dr.setup_test_environment = MagicMock()68 dr.setup_databases = MagicMock()69 dr.teardown_databases = MagicMock()70 dr.teardown_test_environment = MagicMock()71 mock_loadTargets.return_value = None72 mock_fetchdataTestSuite.return_value = 12373 dr.run_tests((), testing=True)74 self.assertEqual(mock_run.call_args[0][0], 123)75 @patch('fetchdata.djangorunner.mergeConfig')76 @patch('fetchdata.djangorunner.fetchdataTestSuite')77 @patch('fetchdata.djangorunner.run')78 @patch('fetchdata.djangorunner.loadTargets')79 def test_run_coverage(self, mock_loadTargets, mock_run, mock_fetchdataTestSuite, mock_mergeConfig):80 """81 If no tests are found, we create an empty test suite and run it.82 """83 args = mergeConfig(Namespace())84 args.run_coverage = True85 args.cov = MagicMock()86 mock_mergeConfig.return_value = args87 dr = djangorunner.DjangoRunner()88 dr.setup_test_environment = MagicMock()89 dr.setup_databases = MagicMock()90 dr.teardown_databases = MagicMock()91 dr.teardown_test_environment = MagicMock()92 mock_loadTargets.return_value = None93 mock_fetchdataTestSuite.return_value = 12394 dr.run_tests((), testing=True)...

Full Screen

Full Screen

evaluateNyström.py

Source:evaluateNyström.py Github

copy

Full Screen

...12 model = loadNormalizedModel()13 dataset = loadDataset()14 test = loadDataset(mode='test')15 val = loadDataset(mode='val')16 Y = loadTargets(dataset)17 os.system(f"python -m plotting.computeKernel computeValidationAndTestKernel {NYSTROM_PATH_EVAL}")18 components = int(fraction * len(dataset))19 nystroem = Nystroem(components, k=None, dataset=dataset, model=model, path=NYSTROM_PATH)20 approximation = nystroem.fit_transform()21 A = solve_system_fast(Kxx=approximation, Y=oneHotEncoding(Y))22 with h5py.File(NYSTROM_PATH_EVAL, 'r') as f:23 Kxvx = load_kern(f['Kxvx'], 0)24 Kxtx = load_kern(f['Kxtx'], 0)25 Yt = loadTargets(test)26 Yv = loadTargets(val)27 print_accuracy(A, Kxvx, Yv, 'validation')28 print_accuracy(A, Kxtx, Yt, 'test')29 end = timer()30 diff = (end - start) / 6031 print(diff)32if __name__ == "__main__":...

Full Screen

Full Screen

evaluateIterativeSVD.py

Source:evaluateIterativeSVD.py Github

copy

Full Screen

...20 Kxtx = load_kern(f['Kxtx'], 0)21 dataset = loadDataset()22 val = loadDataset(mode='val')23 test = loadDataset(mode='test')24 Y = loadTargets(dataset)25 Yv = loadTargets(val)26 Yt = loadTargets(test)27 A = solve_system_fast(approx, oneHotEncoding(Y))28 print_accuracy(A, Kxvx, Yv, 'validation')29 print_accuracy(A, Kxtx, Yt, 'test')30 end = timer()31 diff = (end - start) / 6032 print(diff)33if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run green automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful