Skip to content

Instantly share code, notes, and snippets.

@rpq
Created December 2, 2014 22:08
Show Gist options
  • Save rpq/5655d2cfa7ab6b6c431b to your computer and use it in GitHub Desktop.
Save rpq/5655d2cfa7ab6b6c431b to your computer and use it in GitHub Desktop.
test the django management command snippet
106 fixture = ("/Users/quezadar/projects/b2b-frontend/B2B/src/b2b/tests/"
107 "fixtures/initial_data.json")
108 cmd = 'manage.py loaddata \'%s\'' % (fixture,)
109 s = StringIO.StringIO()
110 sys_stdout = sys.stdout
111 sys_stderr = sys.stderr
112 sys.stdout = s
113 sys.stderr = s
114 execute_from_command_line(cmd.split(' '))
115 sys.stdout = sys_stdout
116 sys.stderr = sys_stderr
117 print('done loading data')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment