3

I'm using django-pipeline for loading static files.

Strange thing is that StaticLiveServerTestCase's live_server_url can not load static files correctly.

Here is part of code:

class ProductSetupTestCase(TestCase):

    @classmethod
    def setUpClass(cls):
        super(ProductSetupTestCase, cls).setUpClass()
        # place category
        cls.place_category = PlaceCategory.objects.create(name="학교")

        # subject category
        cls.subject_category1 = SubjectCategory.objects.create(name="사람")
        cls.subject_category2 = SubjectCategory.objects.create(name="꽃병")

        for i in range(5):
            name = 'name' + str(i)
            product = Product.objects.create(
                name=name,
                place_category=cls.place_category,
            )

            product.subject_category_set.add(cls.subject_category1)
            product.subject_category_set.add(cls.subject_category2)

            product.variation_set.create(color='black')
            product.variation_set.create(color='single')
            product.variation_set.create(color='multi')


class CartItemEditTest(ProductSetupTestCase, StaticLiveServerTestCase):

    def setUp(self):
        self.browser = webdriver.Firefox()
        self.browser.implicitly_wait(2)

Firefox browser comes up and I execute follow command:

self.browser.get(self.live_server_url) # self.live_server_url value is localhost:8081

And when I check js file using development tool, it shows like this:

<script type="text/javascript" src="/static/js/message.8d038600d898.js" charset="utf-8"></script>

When I copy the src(http://localhost:8081/static/js/message.8d038600d898.js) and paste it in new tab, it doesn't show Not Found.

Now I used other url, http:localhost:8000, which is django runserver url.

self.browser.get(http://localhost:8000`)

When I checking this time, it load static files pretty well:

<script type="text/javascript" src="/static/js/message.js" charset="utf-8"></script>

Why does it happend? Should I not use live_server_url anymore?

user3595632
  • 5,380
  • 10
  • 55
  • 111
  • I've not used django-pipeline, but just discovered selenium browsers also do caching (of course), could this be a case of that? – Danimal Sep 15 '17 at 09:10
  • @Danimal No, I'm experiencing the same problem and, by setting a long Selenium wait timeout, I'm able to open the DOM inspector and poke around. It's trying to make the request, but it's getting a 404 error. – ssokolow Nov 20 '17 at 05:40

0 Answers0