我正在使用Django 1.9.6。例如,我在models.py
文件中有以下模型:
class Question(BaseModel):
question_text = models.CharField(max_length=500, unique=True)
class Meta:
verbose_name = 'Question'
verbose_name_plural = 'Questions'
def __unicode__(self):
return (
u"Question id: {}".format(self.id)
)
并在tests.py
我正在运行以下测试:
class TestQuestionModel(TestCase):
def setUp(self):
Question.objects.create(question_text="What is the airspeed velocity of an unladen swallow?")
def test_simple_questions(self):
simpleQuestion = Question.objects.get(question_text="What is the airspeed velocity of an unladen swallow?")
self.assertEqual(simpleQuestion.question_text, "What is the airspeed velocity of an unladen swallow?")
我正在使用postgres数据库。这一切都在当地很有效。
我知道我需要将输出转换为JUnit XML以在Bamboo中运行测试,但是我有点陷入困境。 This answer让我90%的路上,但我正在努力找出postgres部分。我在JUnit Parser之前运行的脚本如下:
#installing pip locally
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py --root=${bamboo.build.working.directory}/tmp --ignore-installed
export PATH=${bamboo.build.working.directory}/tmp/usr/local/bin:$PATH
export PYTHONPATH=${bamboo.build.working.directory}/tmp/usr/local/lib/python2.7/dist-packages:$PYTHONPATH
echo Pip is located `which pip`
# setting up virtualenv
pip install --root=${bamboo.build.working.directory}/tmp --ignore-installed virtualenv
virtualenv .
. bin/activate
# get pg_config
apt-get install libpq-dev python-dev
# from the backend/Dockerfile
pip install --no-cache-dir -r requirements.txt
# running tests into JUnit XML format
python ./manage.py test --junitxml=test-reports\results.xml
我收到了几个错误:
E:无法打开锁定文件/ var / lib / dpkg / lock - open(13:Permission denied) E:无法锁定管理目录(/ var / lib / dpkg /),你是root用户吗?
命令" python setup.py egg_info"在/ tmp / pip-build-ZV8Jz0 / psycopg2 /
中出现错误代码1失败追踪(最近一次通话): 文件" ./ manage.py",第6行,in 来自django.core.management import execute_from_command_line ImportError:没有名为django.core.management的模块
有人可以帮助我克服这个问题吗?