added file reader offset
This commit is contained in:
		
							parent
							
								
									723d004e5c
								
							
						
					
					
						commit
						c23b286540
					
				
					 5 changed files with 80 additions and 2 deletions
				
			
		
							
								
								
									
										29
									
								
								tests/test_read_offset.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								tests/test_read_offset.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| #!/usr/bin/env python3 | ||||
| import sys, os | ||||
| from time import sleep | ||||
| import tempfile | ||||
| sys.path.append(".") | ||||
| sys.path.append("src/") | ||||
| import uuid | ||||
| TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' | ||||
| print("Test directory:", TEST_DIR) | ||||
| os.environ["ONIONR_HOME"] = TEST_DIR | ||||
| import unittest, json | ||||
| 
 | ||||
| from utils import identifyhome, createdirs, readoffset | ||||
| from onionrsetup import setup_config | ||||
| createdirs.create_dirs() | ||||
| setup_config() | ||||
| 
 | ||||
| class TestReadOffset(unittest.TestCase): | ||||
|     def test_read_whole(self): | ||||
|         temp = tempfile.mkstemp()[1] | ||||
|         f = open(temp, 'wb') | ||||
|         data = b"test1\ntest2\ntest3\test4" | ||||
|         f.write(data) | ||||
|         f.close() | ||||
|         self.assertEqual(readoffset.read_from_offset(temp).data, data) | ||||
|         os.remove(temp) | ||||
| 
 | ||||
| 
 | ||||
| unittest.main() | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue