Uploaded Test files
This commit is contained in:
		
							parent
							
								
									f584ad9d97
								
							
						
					
					
						commit
						2e81cb7d99
					
				
					 16627 changed files with 2065359 additions and 102444 deletions
				
			
		
							
								
								
									
										105
									
								
								venv/Lib/site-packages/nbformat/v4/tests/test_validate.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								venv/Lib/site-packages/nbformat/v4/tests/test_validate.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,105 @@ | |||
| """Tests for nbformat validation""" | ||||
| 
 | ||||
| # Copyright (c) IPython Development Team. | ||||
| # Distributed under the terms of the Modified BSD License. | ||||
| 
 | ||||
| import io | ||||
| import os | ||||
| 
 | ||||
| import pytest | ||||
| 
 | ||||
| from nbformat.validator import validate, ValidationError | ||||
| from ..nbjson import reads | ||||
| from ..nbbase import ( | ||||
|     nbformat, | ||||
|     new_code_cell, new_markdown_cell, new_notebook, | ||||
|     new_output, new_raw_cell, | ||||
| ) | ||||
| 
 | ||||
| def validate4(obj, ref=None): | ||||
|     return validate(obj, ref, version=nbformat) | ||||
| 
 | ||||
| def test_valid_code_cell(): | ||||
|     cell = new_code_cell() | ||||
|     validate4(cell, 'code_cell') | ||||
| 
 | ||||
| def test_invalid_code_cell(): | ||||
|     cell = new_code_cell() | ||||
| 
 | ||||
|     cell['source'] = 5 | ||||
|     with pytest.raises(ValidationError): | ||||
|         validate4(cell, 'code_cell') | ||||
| 
 | ||||
|     cell = new_code_cell() | ||||
|     del cell['metadata'] | ||||
| 
 | ||||
|     with pytest.raises(ValidationError): | ||||
|         validate4(cell, 'code_cell') | ||||
| 
 | ||||
|     cell = new_code_cell() | ||||
|     del cell['source'] | ||||
| 
 | ||||
|     with pytest.raises(ValidationError): | ||||
|         validate4(cell, 'code_cell') | ||||
| 
 | ||||
|     cell = new_code_cell() | ||||
|     del cell['cell_type'] | ||||
| 
 | ||||
|     with pytest.raises(ValidationError): | ||||
|         validate4(cell, 'code_cell') | ||||
| 
 | ||||
| def test_invalid_markdown_cell(): | ||||
|     cell = new_markdown_cell() | ||||
| 
 | ||||
|     cell['source'] = 5 | ||||
|     with pytest.raises(ValidationError): | ||||
|         validate4(cell, 'markdown_cell') | ||||
| 
 | ||||
|     cell = new_markdown_cell() | ||||
|     del cell['metadata'] | ||||
| 
 | ||||
|     with pytest.raises(ValidationError): | ||||
|         validate4(cell, 'markdown_cell') | ||||
| 
 | ||||
|     cell = new_markdown_cell() | ||||
|     del cell['source'] | ||||
| 
 | ||||
|     with pytest.raises(ValidationError): | ||||
|         validate4(cell, 'markdown_cell') | ||||
| 
 | ||||
|     cell = new_markdown_cell() | ||||
|     del cell['cell_type'] | ||||
| 
 | ||||
|     with pytest.raises(ValidationError): | ||||
|         validate4(cell, 'markdown_cell') | ||||
| 
 | ||||
| def test_invalid_raw_cell(): | ||||
|     cell = new_raw_cell() | ||||
| 
 | ||||
|     cell['source'] = 5 | ||||
|     with pytest.raises(ValidationError): | ||||
|         validate4(cell, 'raw_cell') | ||||
| 
 | ||||
|     cell = new_raw_cell() | ||||
|     del cell['metadata'] | ||||
| 
 | ||||
|     with pytest.raises(ValidationError): | ||||
|         validate4(cell, 'raw_cell') | ||||
| 
 | ||||
|     cell = new_raw_cell() | ||||
|     del cell['source'] | ||||
| 
 | ||||
|     with pytest.raises(ValidationError): | ||||
|         validate4(cell, 'raw_cell') | ||||
| 
 | ||||
|     cell = new_raw_cell() | ||||
|     del cell['cell_type'] | ||||
| 
 | ||||
|     with pytest.raises(ValidationError): | ||||
|         validate4(cell, 'raw_cell') | ||||
| 
 | ||||
| def test_sample_notebook(): | ||||
|     here = os.path.dirname(__file__) | ||||
|     with io.open(os.path.join(here, os.pardir, os.pardir, 'tests', "test4.ipynb"), encoding='utf-8') as f: | ||||
|         nb = reads(f.read()) | ||||
|     validate4(nb) | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue