File diff 73cd942a4606 → 21f6d078a285
tests/test_outfile.py
Show inline comments
 
new file 100644
 
import pathlib
 
import tempfile
 

	
 
import pytest
 

	
 
from import2ledger import outfile
 

	
 
@pytest.mark.parametrize('to_path', [
 
    lambda s: s,
 
    pathlib.Path,
 
])
 
def test_output_path(to_path):
 
    with tempfile.NamedTemporaryFile() as source_file:
 
        path_arg = to_path(source_file.name)
 
        with outfile.open(path_arg, None) as actual:
 
            assert actual.name == source_file.name
 
            assert 'a' in actual.mode
 

	
 
def test_fallback():
 
    with tempfile.NamedTemporaryFile() as source_file:
 
        with outfile.open('-', source_file) as actual:
 
            assert actual is source_file
 
        assert not source_file.closed