[lang-ref] ( get_source_file_path ) ( python )
def test_get_source_file_path():
# __file__
''' examples/get_source_file_path.py
import sys
def print_file_path():
print(__file__)
if __name__ == '__main__':
print_file_path()
'''
''' examples/get_source_file_path_call.py
import get_source_file_path
get_source_file_path.print_file_path()
'''
r = subprocess.run([sys.executable, 'examples/get_source_file_path.py'], capture_output=True, text=True, check=True)
assert r.stdout.rstrip().endswith('examples/get_source_file_path.py')
r = subprocess.run([sys.executable, 'examples/get_source_file_path_call.py'], capture_output=True, text=True, check=True)
assert r.stdout.rstrip().endswith('examples/get_source_file_path.py')