mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 07:57:35 +03:00 
			
		
		
		
	avoid the tests interacting with eachother through the global Underscore variable
This commit is contained in:
		
							parent
							
								
									7939c63886
								
							
						
					
					
						commit
						6e717c62ed
					
				|  | @ -3,11 +3,17 @@ from __future__ import unicode_literals | ||||||
| 
 | 
 | ||||||
| from spacy.lang.en import English | from spacy.lang.en import English | ||||||
| from spacy.pipeline import EntityRuler | from spacy.pipeline import EntityRuler | ||||||
|  | from spacy.tokens.underscore import Underscore | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_issue4849(): | def test_issue4849(): | ||||||
|     nlp = English() |     nlp = English() | ||||||
| 
 | 
 | ||||||
|  |     # reset the Underscore object because test_underscore has a lambda function that can't be pickled | ||||||
|  |     Underscore.doc_extensions = {} | ||||||
|  |     Underscore.span_extensions = {} | ||||||
|  |     Underscore.token_extensions = {} | ||||||
|  | 
 | ||||||
|     ruler = EntityRuler( |     ruler = EntityRuler( | ||||||
|         nlp, patterns=[ |         nlp, patterns=[ | ||||||
|             {"label": "PERSON", "pattern": 'joe biden', "id": 'joe-biden'}, |             {"label": "PERSON", "pattern": 'joe biden', "id": 'joe-biden'}, | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ from __future__ import unicode_literals | ||||||
| import spacy | import spacy | ||||||
| from spacy.lang.en import English | from spacy.lang.en import English | ||||||
| from spacy.tokens import Span, Doc | from spacy.tokens import Span, Doc | ||||||
|  | from spacy.tokens.underscore import Underscore | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class CustomPipe: | class CustomPipe: | ||||||
|  | @ -31,6 +32,12 @@ class CustomPipe: | ||||||
| 
 | 
 | ||||||
| def test_issue4903(): | def test_issue4903(): | ||||||
|     # ensures that this runs correctly and doesn't hang or crash on Windows / macOS |     # ensures that this runs correctly and doesn't hang or crash on Windows / macOS | ||||||
|  | 
 | ||||||
|  |     # reset the Underscore object because test_underscore has a lambda function that can't be pickled | ||||||
|  |     Underscore.doc_extensions = {} | ||||||
|  |     Underscore.span_extensions = {} | ||||||
|  |     Underscore.token_extensions = {} | ||||||
|  | 
 | ||||||
|     nlp = English() |     nlp = English() | ||||||
|     custom_component = CustomPipe() |     custom_component = CustomPipe() | ||||||
|     nlp.add_pipe(nlp.create_pipe("sentencizer")) |     nlp.add_pipe(nlp.create_pipe("sentencizer")) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user