2👍
✅
This was a disaster on my end, I was doing it incorrectly
Incorrect and actual that I wrote
PLAYLIST = 'playlist'
class PlaylistTest(TestCase):
def insert_playlist(playlist_name=PLAYLIST):
Playlist.objects.add_playlist(playlist_name)
def test_add_one_video_to_playlist(self):
self.insert_playlist()
self.assertEqual(Playlist.objects.count(), 1, msg='playlist count is not 1, it is ' + str(Playlist.objects.count()))
I forgot to add self
to my class method, which is why class instance was being passed all the time
Correct implementation
PLAYLIST = 'playlist'
class PlaylistTest(TestCase):
def insert_playlist(self, playlist_name=PLAYLIST): # added self as first parameter here
Playlist.objects.add_playlist(playlist_name)
def test_add_one_video_to_playlist(self):
self.insert_playlist()
self.assertEqual(Playlist.objects.count(), 1, msg='playlist count is not 1, it is ' + str(Playlist.objects.count()))
and things started to work fine!
thanks for all who answered and thought about the problem
Source:stackexchange.com