# Verify that PyInstaller can load a script from a file with no extension, not just from ``.py`` files.
#
# Also check that both `__file__` attribute and the `co_filename` attribute of the code object have correct suffix.
import os
import sys

print('Hello!')

# Look up and display all relevant attributes...
print(f"__file__: {__file__}")
loader = sys.modules[__name__].__loader__
print(f"loader: {loader}")
co = loader.get_code(__name__)
print(f"co_filename: {co.co_filename}")

# ... before validating them.
# We expect a .py suffix to be added to both attributes. This behavior specific to frozen application; in unfrozen
# script, the suffix should be empty.
if getattr(sys, 'frozen', False):
    assert os.path.splitext(__file__)[1] == '.py'
    assert os.path.splitext(co.co_filename)[1] == '.py'
else:
    assert os.path.splitext(__file__)[1] == ''
    assert os.path.splitext(co.co_filename)[1] == ''
