Skip to content
Snippets Groups Projects
Commit 2a9dc34c authored by Daniele Tavagnacco's avatar Daniele Tavagnacco
Browse files

setup project

parent 7f36f118
No related branches found
No related tags found
No related merge requests found
test_file.txt
# program.py
import os
def main():
filename = 'test_file.txt'
try:
with open(filename, 'r') as file_in:
content = file_in.read()
messages = [f'Found file {filename}', f'That contains {content}']
print('\n'.join(messages))
except FileNotFoundError:
print(f'Creating file {filename}')
with open(filename, 'w') as file_out:
file_out.write('empty')
if (value:= os.getenv('GLOBAL_VAR_FOR_CI')) is not None:
return f'Hello, {value}!'
else:
return('Hello, GitLab CI/CD!')
if __name__ == "__main__":
out = main()
print(out)
# test_program.py
import unittest
from program import main
class TestStringMethods(unittest.TestCase):
def test_output(self):
res = main()
self.assertEqual('Hello, GitLab CI/CD!', res)
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment