Re: Testing if a view have an html element with at least one attribute

2016-08-03 Thread Fred Stluka
Ludovic, On my project, we have lots of test cases that do a GET or POST and then check the returned HTML.  We use the BeautifulSoup HTML parser from our Django tests to avoid the types of errors you're getting with simple string comparisons.  I'm not sure if

Re: Testing if a view have an html element with at least one attribute

2016-07-31 Thread Andreas Kuhne
Jupp, thats about what I meant :-) Probably the best way, if you don't want to check text. Regards, Andréas 2016-07-31 18:01 GMT+02:00 ludovic coues : > Currently, I am using lxml. More dependencies but it's the cleanest > method I've found currently. > I use it like that: >

Re: Testing if a view have an html element with at least one attribute

2016-07-31 Thread ludovic coues
Currently, I am using lxml. More dependencies but it's the cleanest method I've found currently. I use it like that: from django.test import TestCase from lxml import etree class FormTest(TestCase): def test_input(self): response =

Re: Testing if a view have an html element with at least one attribute

2016-07-31 Thread Andreas Kuhne
2016-07-31 15:59 GMT+02:00 ludovic coues : > Oh, sorry. A bit of misunderstanding and miscommunication on my part. > > The exemple I gave is just a quick way to reproduce my problem. The > real test use self.client, reverse, cast response.content to a string. > What I gave is a

Re: Testing if a view have an html element with at least one attribute

2016-07-31 Thread ludovic coues
Oh, sorry. A bit of misunderstanding and miscommunication on my part. The exemple I gave is just a quick way to reproduce my problem. The real test use self.client, reverse, cast response.content to a string. What I gave is a minimal exemple. Also, I assumed you talked about comparing bit of

Re: Testing if a view have an html element with at least one attribute

2016-07-31 Thread Andreas Kuhne
2016-07-31 13:56 GMT+02:00 ludovic coues : > First, thanks for the suggestion. > > I just tried that, didn't work. > Here is the test file I used: > > > from django.test import TestCase > > class HTMLTestCase(TestCase): > > def test_input_in_fieldset(self): >

Re: Testing if a view have an html element with at least one attribute

2016-07-31 Thread ludovic coues
First, thanks for the suggestion. I just tried that, didn't work. Here is the test file I used: from django.test import TestCase class HTMLTestCase(TestCase): def test_input_in_fieldset(self): fieldset = """ """

Re: Testing if a view have an html element with at least one attribute

2016-07-31 Thread Andreas Kuhne
2016-07-31 12:38 GMT+02:00 ludovic coues : > Hello, > > I am trying to test if a view is displaying a form with an input > element with name=username. > > Currently, I have tried a lot of variation around > `self.assertContains( response, "", > html=True)` but none work. > I

Testing if a view have an html element with at least one attribute

2016-07-31 Thread ludovic coues
Hello, I am trying to test if a view is displaying a form with an input element with name=username. Currently, I have tried a lot of variation around `self.assertContains( response, "", html=True)` but none work. I assume that doesn't work because the view have a field input with name=username