Best Python code snippet using avocado_python
test_visualization.py
Source:test_visualization.py
...13 from pydiffmap import visualization as viz14 import matplotlib.pyplot as plt15 class TestEmbeddingPlot():16 @pytest.mark.parametrize('dim', [2, 3])17 def test_no_kwargs(self, dummy_dmap, dim):18 mydmap = dummy_dmap19 fig = viz.embedding_plot(mydmap, dim=dim, scatter_kwargs=None, show=False)20 assert(fig)21 def test_fixed_coloring(self, dummy_dmap):22 mydmap = dummy_dmap23 scatter_kwargs = {'c': 'r'}24 true_coloring = (1.0, 0., 0., 1)25 fig = viz.embedding_plot(mydmap, scatter_kwargs=scatter_kwargs, show=False)26 SC = fig.axes[0].collections[0]27 assert(np.all(SC._facecolors[0] == true_coloring))28 @pytest.mark.parametrize('size', [4., np.arange(1, 82)])29 def test_size(self, dummy_dmap, size):30 mydmap = dummy_dmap31 scatter_kwargs = {'s': size}32 fig = viz.embedding_plot(mydmap, scatter_kwargs=scatter_kwargs, show=False)33 SC = fig.axes[0].collections[0]34 actual_sizes = SC.get_sizes()35 assert(np.all(actual_sizes == size))36 @pytest.mark.parametrize('cmap', [None, 'Blues', plt.cm.Spectral])37 def test_colormap(self, dummy_dmap, cmap):38 # This just tests if the code runs...39 # Replace with something more stringent?40 mydmap = dummy_dmap41 scatter_kwargs = {'c': mydmap.dmap[:, 0], 'cmap': cmap}42 fig = viz.embedding_plot(mydmap, scatter_kwargs=scatter_kwargs, show=False)43 assert(fig)44 class TestDataPlot():45 def test_no_kwargs(self, dummy_dmap):46 mydmap = dummy_dmap47 fig = viz.data_plot(mydmap, scatter_kwargs=None, show=False)48 assert(fig)49 @pytest.mark.parametrize('size', [4., np.arange(1, 82)])50 def test_size(self, dummy_dmap, size):51 mydmap = dummy_dmap52 scatter_kwargs = {'s': size}53 fig = viz.data_plot(mydmap, 1, scatter_kwargs=scatter_kwargs, show=False)54 SC = fig.axes[0].collections[0]55 actual_sizes = SC.get_sizes()...
test_runner_asset.py
Source:test_runner_asset.py
...7class RunnableRun(unittest.TestCase):8 skip_message = (9 "This test depends on internet connectivity. Skipping to run on CI only."10 )11 def test_no_kwargs(self):12 res = process.run(f"{RUNNER} runnable-run -k asset", ignore_status=True)13 self.assertIn(b"'status': 'started'", res.stdout)14 self.assertIn(b"'status': 'finished'", res.stdout)15 self.assertIn(b"At least name should be passed as kwargs", res.stdout)16 self.assertIn(b"'time': ", res.stdout)17 self.assertEqual(res.exit_status, 0)18 @unittest.skipUnless(os.getenv("CI"), skip_message)19 def test_fetch(self):20 name = "name=gpl-2.0.txt"21 locations = "locations=https://mirrors.kernel.org/gnu/Licenses/gpl-2.0.txt"22 res = process.run(23 f"{RUNNER} runnable-run -k asset {name} {locations}", ignore_status=True24 )25 self.assertIn(b"'status': 'started'", res.stdout)26 self.assertIn(b"'status': 'finished'", res.stdout)27 self.assertIn(b"'time': ", res.stdout)28 self.assertIn(b"'log': b'File fetched at", res.stdout)29 self.assertEqual(res.exit_status, 0)30 @unittest.skipUnless(os.getenv("CI"), skip_message)31 def test_recipe(self):32 recipe = os.path.join(33 BASEDIR, "examples", "nrunner", "recipes", "runnables", "asset.json"34 )35 cmd = f"{RUNNER} runnable-run-recipe {recipe}"36 res = process.run(cmd, ignore_status=True)37 self.assertIn(b"'status': 'started'", res.stdout)38 self.assertIn(b"'status': 'finished'", res.stdout)39 self.assertIn(b"'log': b'File fetched at", res.stdout)40 self.assertEqual(res.exit_status, 0)41class TaskRun(unittest.TestCase):42 def test_no_kwargs(self):43 res = process.run(44 f"{RUNNER} task-run -i XXXreq-pacXXX -k asset", ignore_status=True45 )46 self.assertIn(b"'status': 'finished'", res.stdout)47 self.assertIn(b"'result': 'error'", res.stdout)48 self.assertIn(b"'id': 'XXXreq-pacXXX'", res.stdout)49 self.assertEqual(res.exit_status, 0)50if __name__ == "__main__":...
7bd97bc693a2e86ddb989a17f48e56ff9ade82c3test_async_dispatch.py
Source:7bd97bc693a2e86ddb989a17f48e56ff9ade82c3test_async_dispatch.py
...7 query = { '3*2': (f, [3], {'m': 2}), '2*4': (f, [2], {'m': 4}) }8 expected = { '3*2': 6, '2*4': 8 }9 self.assertEqual(async_dispatch(query), expected)10 11 def test_no_kwargs(self):12 query = { '3*2': (f, [3]), '2*2': (f, [2]) }13 expected = { '3*2': 6, '2*2': 4 }14 self.assertEqual(async_dispatch(query), expected)15 16 def tests_no_args(self):17 query = { '3*2': (f,) }18 expected = { '3*2': 6 }...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!