I want to generate dynamically the name of a yaml file based on the name of a python script. Generally this is my naming convention:
if test name is test_action_01.py
then the yaml file name should be action_01.yml
So to acheive that I have these two lines in the python script (inside test_action_01.py) :
file_name = (os.path.basename(__file__).replace("test_", "")).replace(".py", ".yml")
pb_path = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '../playbooks', file_name))
with open(pb_path, 'r') as f:
pb = yaml.load(f)
When I run the script I get this strange error:
Traceback (most recent call last):
File "test_create_01.py", line 22, in setUp
with open(pb_path, 'r') as f:
IOError: [Errno 2] No such file or directory: '/data/jenkins/workspace/aws-s3-tests/aws-s3/playbooks/create_01.ymlc'
I don't understand from where the extra "c" character somes from ?
I'm using Python2.7
.