How can I write unittests in Python (3.4), which are not dependent on any django stuff?
At first I thought Pycharm did somehow artifically add django dependencies to my unittests, but then I checked by just running
python <test containing file>
And I still get this weird django output:
Traceback (most recent call last):
File "test_pinyinTones2NumbersTransformer.py", line 2, in <module> from PinyinTones2NumbersTransformer import PinyinTones2NumbersTransformer
File "/home/xiaolong/PycharmProjects/PinyinTransformer/pinyintransformer/PinyinTones2NumbersTransformer.py", line 1, in <module> from django.contrib.gis.gdal.prototypes.generation import void_output
ImportError: No module named 'django'
Here is my source code of the test file:
import unittest
from PinyinTones2NumbersTransformer import PinyinTones2NumbersTransformer
class TestPinyinTones2NumbersTransformer(unittest.TestCase):
def setUp(self):
self.pinyin_tones_2_numbers_transformer = PinyinTones2NumbersTransformer()
def test_setText (self):
self.fail()
def test_transform (self):
self.fail()
def test_getToneNumberOfTonedSyllable (self):
self.assertEquals(self.pinyin_tones_2_numbers_transformer.getToneNumberOfTonedSyllable("ne"), 0)
self.assertEquals(self.pinyin_tones_2_numbers_transformer.getToneNumberOfTonedSyllable("ān"), 1)
self.assertEquals(self.pinyin_tones_2_numbers_transformer.getToneNumberOfTonedSyllable("péng"), 2)
self.assertEquals(self.pinyin_tones_2_numbers_transformer.getToneNumberOfTonedSyllable("nǐ"), 3)
self.assertEquals(self.pinyin_tones_2_numbers_transformer.getToneNumberOfTonedSyllable("jiào"), 4)
My project has absolutely nothing to do with django. I've tried a django tutorial before, but that had nothing to do with what I am doing now. Also I deleted django after seeing this message, because I thought maybe the Python interpreter is confused with django also having a module called unittest, but that didn't fix the issue.
I found this:
http://ift.tt/1xl2UTo
But first of all: I am using Python 3.4 and I don't care about backwards compatibility of my tests. No one else will probably see or maybe even use my programm anyways. It's just a sort of exercise for myself, to get more used to writing tests.
All I want to do is write simple tests for the methods in my classes, without any django bonus super mega ... Also I am quite sure that default unittests of Python itself are more than enough for my little project.
Aucun commentaire:
Enregistrer un commentaire