jeudi 21 juin 2018

Testing a python script with pytest - permission issues

I have unit tested my modules using pytest without issue. I would also like to test my script (which imports some of the modules), but I am getting a permission error. I am new to writing larger python projects that actually need to be tested and maintained, so my directory structure may be non-optimal, so please let me know if that is the case. My directory structure looks like -

parent
 modules
  __init__.py
  module1.py
  ...
 test
  ...
  test_script.py
 script.py

My test code:

import os
import subprocess
import train

def test_train_dataset1():
  #run the script
  p = subprocess.Popen(['./train.py', 'test_models', 'test1', 'data/temp.json', '--isfile'])
  #more code to check output

My error:

PermissionError: [Errno 13] Permission denied: './train.py'

Aucun commentaire:

Enregistrer un commentaire