How to use compute_checksum method in autotest

Best Python code snippet using autotest_python

test_utils.py

Source:test_utils.py Github

copy

Full Screen

...90 with pytest.raises(ValueError):91 utils.determine_grade(cell)92def test_determine_grade_code_grade_and_solution():93 cell = create_grade_and_solution_cell('test', "code", "foo", 10)94 cell.metadata.nbgrader['checksum'] = utils.compute_checksum(cell)95 cell.outputs = []96 assert utils.determine_grade(cell) == (0, 10)97 cell.outputs = [new_output('error', ename="NotImplementedError", evalue="", traceback=["error"])]98 cell.source = 'test!'99 assert utils.determine_grade(cell) == (None, 10)100def test_determine_grade_markdown_grade_and_solution():101 cell = create_grade_and_solution_cell('test', "markdown", "foo", 10)102 cell.metadata.nbgrader['checksum'] = utils.compute_checksum(cell)103 assert utils.determine_grade(cell) == (0, 10)104 cell = create_grade_and_solution_cell('test', "markdown", "foo", 10)105 cell.source = 'test!'106 assert utils.determine_grade(cell) == (None, 10)107def test_compute_checksum_identical():108 # is the same for two identical cells?109 cell1 = create_grade_cell("hello", "code", "foo", 1)110 cell2 = create_grade_cell("hello", "code", "foo", 1)111 assert utils.compute_checksum(cell1) == utils.compute_checksum(cell2)112 cell1 = create_solution_cell("hello", "code", "foo")113 cell2 = create_solution_cell("hello", "code", "foo")114 assert utils.compute_checksum(cell1) == utils.compute_checksum(cell2)115def test_compute_checksum_cell_type():116 # does the cell type make a difference?117 cell1 = create_grade_cell("hello", "code", "foo", 1)118 cell2 = create_grade_cell("hello", "markdown", "foo", 1)119 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)120 cell1 = create_solution_cell("hello", "code", "foo")121 cell2 = create_solution_cell("hello", "markdown", "foo")122 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)123def test_compute_checksum_whitespace():124 # does whitespace make no difference?125 cell1 = create_grade_cell("hello", "code", "foo", 1)126 cell2 = create_grade_cell("hello ", "code", "foo", 1)127 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)128 cell1 = create_grade_cell("hello", "markdown", "foo", 1)129 cell2 = create_grade_cell("hello ", "markdown", "foo", 1)130 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)131 cell1 = create_solution_cell("hello", "code", "foo")132 cell2 = create_solution_cell("hello ", "code", "foo")133 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)134 cell1 = create_solution_cell("hello", "markdown", "foo")135 cell2 = create_solution_cell("hello ", "markdown", "foo")136 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)137def test_compute_checksum_source():138 # does the source make a difference?139 cell1 = create_grade_cell("print('hello')", "code", "foo", 1)140 cell2 = create_grade_cell("print( 'hello' )", "code", "foo", 1)141 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)142 cell1 = create_grade_cell("print('hello')", "code", "foo", 1)143 cell2 = create_grade_cell("print( 'hello!' )", "code", "foo", 1)144 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)145 cell1 = create_grade_cell("print('hello')", "markdown", "foo", 1)146 cell2 = create_grade_cell("print( 'hello' )", "markdown", "foo", 1)147 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)148 cell1 = create_solution_cell("print('hello')", "code", "foo")149 cell2 = create_solution_cell("print( 'hello' )", "code", "foo")150 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)151 cell1 = create_solution_cell("print('hello')", "code", "foo")152 cell2 = create_solution_cell("print( 'hello!' )", "code", "foo")153 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)154 cell1 = create_solution_cell("print('hello')", "markdown", "foo")155 cell2 = create_solution_cell("print( 'hello' )", "markdown", "foo")156 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)157def test_compute_checksum_points():158 # does the number of points make a difference (only for grade cells)?159 cell1 = create_grade_cell("hello", "code", "foo", 2)160 cell2 = create_grade_cell("hello", "code", "foo", 1)161 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)162 cell1 = create_grade_cell("hello", "code", "foo", 2)163 cell2 = create_grade_cell("hello", "code", "foo", 1)164 cell1.metadata.nbgrader["grade"] = False165 cell2.metadata.nbgrader["grade"] = False166 assert utils.compute_checksum(cell1) == utils.compute_checksum(cell2)167def test_compute_checksum_grade_id():168 # does the grade id make a difference (only for grade cells)?169 cell1 = create_grade_cell("hello", "code", "foo", 1)170 cell2 = create_grade_cell("hello", "code", "bar", 1)171 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)172 cell1 = create_grade_cell("hello", "code", "foo", 1)173 cell2 = create_grade_cell("hello", "code", "bar", 1)174 cell1.metadata.nbgrader["grade"] = False175 cell2.metadata.nbgrader["grade"] = False176 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)177def test_compute_checksum_grade_cell():178 # does it make a difference if grade=True?179 cell1 = create_grade_cell("hello", "code", "foo", 1)180 cell2 = create_grade_cell("hello", "code", "foo", 1)181 cell2.metadata.nbgrader["grade"] = False182 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)183def test_compute_checksum_solution_cell():184 # does it make a difference if solution=True?185 cell1 = create_solution_cell("hello", "code", "foo")186 cell2 = create_solution_cell("hello", "code", "foo")187 cell2.metadata.nbgrader["solution"] = False188 assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)189def test_compute_checksum_utf8():190 utils.compute_checksum(create_solution_cell("\u03b8", "markdown", "foo"))191 utils.compute_checksum(create_solution_cell(u'$$\\int^\u221e_0 x^2dx$$', "markdown", "foo"))192def test_is_ignored(temp_cwd):193 os.mkdir("foo")194 with open(join("foo", "bar.txt"), "w") as fh:195 fh.write("bar")196 assert not utils.is_ignored("foo")197 assert utils.is_ignored(join("foo", "bar.txt"), ["*.txt"])198 assert utils.is_ignored(join("foo", "bar.txt"), ["bar.txt"])199 assert utils.is_ignored(join("foo", "bar.txt"), ["*"])200 assert not utils.is_ignored(join("foo", "bar.txt"), ["*.csv"])201 assert not utils.is_ignored(join("foo", "bar.txt"), ["foo"])202 assert not utils.is_ignored(join("foo", "bar.txt"), [join("foo", "*")])203def test_find_all_files(temp_cwd):204 os.makedirs(join("foo", "bar"))205 with open(join("foo", "baz.txt"), "w") as fh:...

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 autotest 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