-1
class Artist(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    artist_name = db.Column(db.String(200))
    albums = db.relationship('Album',
                            backref='artist',
                            lazy=True)

    def __repr__(self):
        return "<Artist '{}'>".format(self.artist_name)

This is the test class

def test_artists_count(self):
        c = Artist.query.all()
        self.assertEqual(2, c)

This is the error that I am getting

Traceback (most recent call last):enter code here
  File "/projects/challenge/myflaskproj/tests/test_models.py", line 65, in test_artists_count

self.assertEqual(2, c)

AssertionError: 2 != [<Artist 'Artist1'>, <Artist 'Artist2'>]
snakecharmerb
  • 47,570
  • 11
  • 100
  • 153

1 Answers1

0

you can check the number or rows of a query result by checking its length

the only line you need to change is this:

self.assertEqual(2, len(c))

c8999c 3f964f64
  • 1,430
  • 1
  • 12
  • 25
  • Yeah tried that too. Test cases are successful. But after submission it is rejecting that answer – saajid pasha Nov 08 '19 at 15:39
  • What do you mean "after submission"? Is the database you are testing on locally the same database the tests run against after "submission". If not then there could be a different number of artists in each database. – steve Nov 09 '19 at 04:46