Why are my App tests not being recognized by Django tests?
Background:
I have the following django project setup:
>TopLevel:
> - App1:
> * models.py
> * forms.py
> * views.py
> * __init__.py
> * Tests/
> * __init__.py
> * test_simple.py
Here is the code in test_simple.py:
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)
Now, when I run:
> python manage.py test app1
I get the following output:
>Creating test database for alias 'default'...
>
>----------------------------------------------------------------------
>Ran 0 tests in 0.000s
>
>OK
>Destroying test database for alias 'default'...
But, if I instead use the following project structure:
>TopLevel:
> - App1:
> * models.py
> * forms.py
> * views.py
> * __init__.py
> * tests.py
Where tests.py has the following code:
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)
Now, when I run:
> python manage.py test app1
I get:
>Creating test database for alias 'default'...
>.
>----------------------------------------------------------------------
>Ran 1 test in 0.002s
>
>OK
>Destroying test database for alias 'default'...
Question:
Why does Django not recognize my Tests directory && why won't any tests
listed inside Tests/ be picked up by Django's unittest structure to run?
Saturday, 31 August 2013
GetJson parse function
GetJson parse function
here is my code for parsing JSON data of geolocation api of google
var url = "http://maps.googleapis.com/maps/api/geocode/json?address=" +
input.value + "&sensor=false";
var check = $.getJSON(url, function (data) {
console.log("inside getjson");
$.each(data.results.address_components, function(){
if(this.types[0]=="route"){
$("#results").append('<p> route : '+this.long_name +'</p>');
}
if(this.types[0]=="locality"){
$("#results").append('<p> locality : '+this.long_name +'</p>');
}
if(this.types[0]=="administrative_area_level_2"){
$("#results").append('<p> administrative area 2 : '+this.long_name
+'</p>');
}
if(this.types[0]=="administrative_area_level_1"){
$("#results").append('<p> administrative area 1 : '+this.long_name
+'</p>');
}
if(this.types[0]=="country"){
$("#results").append('<p> country : '+this.long_name +'</p>');
}
// latitude1 = data.results[0].geometry.location.lat;
// longitude1 = data.results[0].geometry.location.lng;
//alert(data.results[0].geometry.location.lat);
});
});
but unfortunately it doesn't parse the data properly...firebug throws the
error as e not defined. can you please look into it
here is my code for parsing JSON data of geolocation api of google
var url = "http://maps.googleapis.com/maps/api/geocode/json?address=" +
input.value + "&sensor=false";
var check = $.getJSON(url, function (data) {
console.log("inside getjson");
$.each(data.results.address_components, function(){
if(this.types[0]=="route"){
$("#results").append('<p> route : '+this.long_name +'</p>');
}
if(this.types[0]=="locality"){
$("#results").append('<p> locality : '+this.long_name +'</p>');
}
if(this.types[0]=="administrative_area_level_2"){
$("#results").append('<p> administrative area 2 : '+this.long_name
+'</p>');
}
if(this.types[0]=="administrative_area_level_1"){
$("#results").append('<p> administrative area 1 : '+this.long_name
+'</p>');
}
if(this.types[0]=="country"){
$("#results").append('<p> country : '+this.long_name +'</p>');
}
// latitude1 = data.results[0].geometry.location.lat;
// longitude1 = data.results[0].geometry.location.lng;
//alert(data.results[0].geometry.location.lat);
});
});
but unfortunately it doesn't parse the data properly...firebug throws the
error as e not defined. can you please look into it
How do you uninstall the package manager "pip", if installed from source?
How do you uninstall the package manager "pip", if installed from source?
I was unaware that pip could be installed via my operating system's
package manager, so I compiled and installed pip via source with the
following command:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O -
| sudo python
I would like to uninstall pip, and instead install it from my operating
system's package manager. How would I go about completely undoing the work
of the installation script?
I was unaware that pip could be installed via my operating system's
package manager, so I compiled and installed pip via source with the
following command:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O -
| sudo python
I would like to uninstall pip, and instead install it from my operating
system's package manager. How would I go about completely undoing the work
of the installation script?
Friday, 30 August 2013
HTML Checkbox selected Element keep tick after submit
HTML Checkbox selected Element keep tick after submit
I have check box set when i submit it, i want keep tick what i selected, I
have wrote a code but I want to know any easiest way to do it
<form action="" method="post">
<input type="checkbox" name="car[]"
<?php
if(isset($_POST['submit'])){
if(isset($_POST['car'])){
if(in_array('Bus',$_POST['car']))
{
echo ' checked="checked"" ';
}
}
}
?> value="Bus" />Bus
<input type="checkbox" name="car[]" value="Van"
<?php
if(isset($_POST['submit']))
{
if(isset($_POST['car'])){
if(in_array('Van',$_POST['car']))
{
echo ' checked="checked"" ';
}
}
} ?> />Van
<input type="submit" name="submit" value="Submit" />
</form>
I have check box set when i submit it, i want keep tick what i selected, I
have wrote a code but I want to know any easiest way to do it
<form action="" method="post">
<input type="checkbox" name="car[]"
<?php
if(isset($_POST['submit'])){
if(isset($_POST['car'])){
if(in_array('Bus',$_POST['car']))
{
echo ' checked="checked"" ';
}
}
}
?> value="Bus" />Bus
<input type="checkbox" name="car[]" value="Van"
<?php
if(isset($_POST['submit']))
{
if(isset($_POST['car'])){
if(in_array('Van',$_POST['car']))
{
echo ' checked="checked"" ';
}
}
} ?> />Van
<input type="submit" name="submit" value="Submit" />
</form>
Thursday, 29 August 2013
How to make Dynamic TextBox in C#
How to make Dynamic TextBox in C#
I have simple FormApplication script that contains button and some
TextBoxs. I want when click on button, one textbox shows some numbers. How
I can make that dynamic.
private void button1_Click(object sender, EventArgs e)
{
txt3.Text = "";
for (int i = 0; i <50; i++)
{
Random random = new Random();
int randomNumber = random.Next(100, 150);
txt3.Text = randomNumber.ToString();
}
}
Now it waits to loop finished and shows latest number. I want it shows
each number during loop in TextBox seperatly. Seems using Dynamic TextBox
is a bit hard, is there any other solution to show this numbers in main
form? Regards,
I have simple FormApplication script that contains button and some
TextBoxs. I want when click on button, one textbox shows some numbers. How
I can make that dynamic.
private void button1_Click(object sender, EventArgs e)
{
txt3.Text = "";
for (int i = 0; i <50; i++)
{
Random random = new Random();
int randomNumber = random.Next(100, 150);
txt3.Text = randomNumber.ToString();
}
}
Now it waits to loop finished and shows latest number. I want it shows
each number during loop in TextBox seperatly. Seems using Dynamic TextBox
is a bit hard, is there any other solution to show this numbers in main
form? Regards,
password for Login Application in c# windows form
password for Login Application in c# windows form
How to display password as "**" in the text box instead of displaying real
password on text box? Is it possible in c#
Thanks
How to display password as "**" in the text box instead of displaying real
password on text box? Is it possible in c#
Thanks
clang -cc1 and system includes
clang -cc1 and system includes
I have the following file foo.cpp:
#include <vector>
struct MyClass
{
std::vector<int> v;
};
It can be successfully compiled with clang (I'm using clang 3.3 on Ubuntu
13.04 32bit):
clang++ -c foo.cpp
Now I want to print AST:
clang++ -cc1 -ast-print foo.cpp
and I've got the following error
foo.cpp:1:10: fatal error: 'vector' file not found
#include <vector>
^
struct MyClass {
};
1 error generated.
It looks like clang++ -cc1 doesn't know about system include files etc.
I'm wondering how to set up includes for clang++ -cc1?
I have the following file foo.cpp:
#include <vector>
struct MyClass
{
std::vector<int> v;
};
It can be successfully compiled with clang (I'm using clang 3.3 on Ubuntu
13.04 32bit):
clang++ -c foo.cpp
Now I want to print AST:
clang++ -cc1 -ast-print foo.cpp
and I've got the following error
foo.cpp:1:10: fatal error: 'vector' file not found
#include <vector>
^
struct MyClass {
};
1 error generated.
It looks like clang++ -cc1 doesn't know about system include files etc.
I'm wondering how to set up includes for clang++ -cc1?
Subscribe to:
Posts (Atom)