Trying to use Python TestRail API on Mac - ImportError : No module named Conf_Reader

Trying to use Python TestRail API on Mac - ImportError : No module named Conf_Reader

我在 Mac 上收到以下导入错误:

ImportError: No module named Conf_Reader

这是我的 Python 代码的几行开头:

import dotenv
import os
import testrail
import Conf_Reader

#setup the testrail client and connect to the testrail instance
def get_testrail_client():
    testrail_file = os.path.join(os.path.dirname(__file__),'testrail.env')
    testrail_url = Conf_Reader.get_value(testrail_file,'TESTRAIL_URL')
    client = testrail.APIClient(testrail_url)
..
..
..

目前已尝试使用 pip,但无法找到任何安装源。

我在 Mac 上遇到了同样的问题。 为避免使用其他独立性,您可以跳过使用 env。但作为变量传递:

# create a credential.py
TESTRAIL_URL='https://testrail.com/testrail'
TESTRAIL_USER='xxxxx'
TESTRAIL_PASSWORD = 'xxxxx'
# on your update_testrail.py
from credential import TESTRAIL_URL, 
TESTRAIL_USER, 
TESTRAIL_PASSWORD

testrail_url = TESTRAIL_URL
client = testrail.APIClient(testrail_url)
# Get and set the TestRail User and Password
client.user = TESTRAIL_USER
client.password = TESTRAIL_PASSWORD

他们应该链接到 https://bangladroid.wordpress.com/2016/08/20/create-separate-credential-files-for-selenium-python/

说明您制作自己的“Conf_Reader.py”文件的地方如下:

"""
A simple conf reader.
For now, we just use dotenv and return a key.
"""

import dotenv,os

def get_value(conf,key):
    # type: (object, object) -> object
    "Return the value in conf for a given key"
    value = None
    try:
        dotenv.load_dotenv(conf)
        value = os.environ[key]
    except Exception,e:
        print 'Exception in get_value'
        print 'file: ',conf
        print 'key: ',key

    return value