Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLarry McGee
6,023 PointsWhy does TDD test pass in workspace but fail in challenge?
I am re-posting this question and would appreciate some help in understanding how to get a resolution. All 5 tests pass in the workspace, however, when I cut and paste into the challenge I receive a message: "Bummer! Not all tests are passing."
What could cause the tests to fail in the challenge while passing in the workspace?
from django.db import models
from django.core.urlresolvers import reverse
# Write your models here
class Performer(models.Model):
name = models.CharField(max_length=50)
def __str__(self):
return '{}'.format(self.name)
class Song(models.Model):
"""
Songs for karoke
"""
title = models.CharField(max_length=200)
artist = models.CharField(max_length=200)
duration = models.IntegerField()
performer = models.ForeignKey(Performer, on_delete=models.CASCADE)
def __str__(self):
return '{} by {}'.format(self.title, self.artist)
from django.http import HttpResponse
from django.shortcuts import render, get_object_or_404
from .models import Performer, Song
def home(request):
return render(request, 'home.html')
def song_list(request):
songs = Song.objects.all()
return render(request, 'songs/song_list.html', {'songs': songs})
def song_detail(request, pk):
song = get_object_or_404(Song, pk=pk)
return render(request, 'songs/song_detail.html', {'songs': song})
def performer_detail(request, pk):
performer = get_object_or_404(Performer, pk=pk)
songs = Song.objects.filter(performer=performer)
return render(request, 'songs/performer_detail.html', {'performer': performer})
{% extends 'base.html' %}
{% block title %}{{ performer }}{% endblock %}
{% block content %}
<h2>{{ performer }}</h2>
{% for song in performer.song_set.all %}
{{ song }}
{% endfor %}
{% endblock %}
Larry McGee
6,023 PointsThanks Jason for your comments: My dilemma continues to be that when I run the test in Workspace it passes but only fails in the challenge!
1 Answer
Jason Grunill
8,603 PointsHi Larry, I've cracked it when I copied your code in.
- Your song_detail function is passing {'songs': song} I think this should be {'song': song}
- In your Song model change your field name "duration" to "length"
- Passes for me with your code and these two changes.
Larry McGee
6,023 PointsThanks Jason for your help. That enabled me to pass the challenge. Interesting that those changes don't pass in Workspace but I can continue to debug that issue on my own.
Thanks again.
Jason Grunill
8,603 PointsJason Grunill
8,603 PointsHi, I can spot two things that don't look right but just a beginner myself so not posting this as an answer.