{"id":581,"date":"2012-04-27T20:17:00","date_gmt":"2012-04-28T01:17:00","guid":{"rendered":"http:\/\/crschmidt.net\/blog\/?p=581"},"modified":"2012-04-27T20:17:00","modified_gmt":"2012-04-28T01:17:00","slug":"python-simplehttpserver-openlayers-testing","status":"publish","type":"post","link":"https:\/\/crschmidt.net\/blog\/archives\/581\/python-simplehttpserver-openlayers-testing\/","title":{"rendered":"python SimpleHTTPServer + OpenLayers testing"},"content":{"rendered":"<p>OpenLayers testing for new users was always felt a bit odd at things like code sprints: because the OpenLayers tests use XMLHttpRequest, Popup windows, and the like, there was always an issue of a few tests that would fail outside of being run on an HTTP server. For a product where almost all the tests pass just fine without it, I always found it sort of annoying that a few minor XMLHttpRequest restrictions forced me to shell out to a server.<\/p>\n<p>This weekend, as I was helping at the OpenHatch Open Source workshop at RPI, I found myself in a position where a new developer was running the tests, and asking me why they failed. I was pointing out that in order for them to pass, they&#8217;d have to be run from a webserver, and someone else in the room helpfully pointed out that if you have Python installed, you have a webserver available to you with just one line of code.<\/p>\n<p>&#8220;What?&#8221; I said, incredulously. I mean, I believed them &#8212; in the same way that python -mjson.tool has become a daily part of my life, I&#8217;m not entirely surprised by Python modules offering useful command line interactions that help make my life easier. Still, this was a new one to me.<\/p>\n<p>&#8220;Sure&#8221;, came the reply. &#8220;Just use <code>python -m SimpleHTTPServer<\/code> in the directory you want to serve.&#8221;<\/p>\n<p>And I `cd`&#8217;d into the root of my OpenLayers checkout, and typed python -m SimpleHTTPServer, and went to http:\/\/localhost:8000\/tests\/run-tests.html &#8212; and &#8216;lo, the tests did pass, and the developer did say it was Good.<\/p>\n<p>(I probably learned more tips and tricks in the two day workshop about git, and other helpful tools, than I do in a week of doing my own development. Kids these days, teaching me new things!)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenLayers testing for new users was always felt a bit odd at things like code sprints: because the OpenLayers tests use XMLHttpRequest, Popup windows, and the like, there was always an issue of a few tests that would fail outside of being run on an HTTP server. For a product where almost all the tests [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-581","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts\/581","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/comments?post=581"}],"version-history":[{"count":0,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts\/581\/revisions"}],"wp:attachment":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/media?parent=581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/categories?post=581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/tags?post=581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}