Posts Tagged ‘Python’
Friday, February 15th, 2008
Oh yeah. I forgot about this until now.
In Python, ([] == []) == True.
In ActionScript (and JavaScript and EMCAScript), ([] == []) == false.
Task number one for tomorrow: make it easy to compare Array objects using assertEquals within FlexUnit tests.
Tags: actionscript, flash, flex, flexunit, Python
Posted in Uncategorized | No Comments »
Thursday, February 14th, 2008
I don't have time to update the HOWTOs associated with this before I end my day at the computer, but I had an ah ha! moment this evening with regard to getting FlexUnit to play nicely with RemoteObject against a PyAMF server.
Changelogs: ah ha moment, refinement and abstraction.
Files: the new test, the new class.
Some observations, where I use terminology loosely:
ActionScript looks superficially like Java, which is a language that I haven't used a lot, but that I've glanced at enough to notice certain patterns.
ActionScript is actually more like JavaScript, but has enough static typing to make it easy to follow Java idioms.
FlexUnit/RemoteObject samples that I've studied seem to define callback functions for asynchronous tests outside of the test case. This is unnecessary, in my opinion, and makes the test case much less readable.
If you look at the example test above, there are five variable assignments, then a call, that comprise the entirety of the test:
- Line 41-42: Trigger an asynchronous operation that will produce a value object that we want to inspect.
- Lines 43-48: Define a function to compare the state of that object with our expectations of it.
- Lines 49-54: Boilerplate to connect the two together.
To me, this is a clearer way of defining tests. I hope to refine this even further by turning item 3 above into one or two lines of code.
To get to that point, my plan is to develop an API for deleting the database collection (if allowed by the server), create an empty named database, list database names, and delete a named database. That should give me enough code to figure out where the lines of fissure are to reduce that boilerplate.
Does anyone else out there know of more FlexUnit tricks? :)
Tags: actionscript, flash, flex, flexunit, pyamf, Python, RemoteObject, remoting, Schevo, schevoflex, testing
Posted in Uncategorized | No Comments »
Tuesday, February 12th, 2008
Using Flex 3 Component without MXML:
This post is a sample AS3 code without any MXML that enables you using Flex Component in pure AS3, initializing manually Flex Application.
This should be an excellent resource for me to use tomorrow. I'm still on my quest to learn Flex and ActionScript by way of test-driven development.
So far, I have dabbled in PyAMF enough to run a remoting server that responds to remoting client code in a Python unit test, confirming that the server side is set up correctly.
The next step is to get a FlexUnit test working that does the same operation.
Not tonight, though! :)
Tags: actionscript, amf, flex, flexunit, pyamf, Python
Posted in Uncategorized | No Comments »
Monday, February 11th, 2008
My current work for Schevo is based on building a combination of a Python server app, an ActionScript client library, and a Flex user interface.
The project mentioned above is in very early stages, but if anyone is interested, I took some notes on creating a new test-driven Python/Flex app.
I plan to expand upon it once I get a good handle on doing an automated client/server test suite. If anyone wants to help edit or expand it, please contact me at gldnspud@gmail.com so I can give you access to the Mercurial repository.
Tags: flex, flexunit, Python, testing, unit testing
Posted in Uncategorized | No Comments »
Wednesday, February 6th, 2008
I'd like to do some test-driven development in Flex right away, but I'm still looking at the options available.
The two main options seem to be ASUnit and FlexUnit.
ASUnit is the older of the two, but I think from what I've read so far I'm going to look at FlexUnit first, and if it does what I'm looking for, I'll just use it.
As far as how to get started writing tests for ActionScript code, I see there is also the corelib that Adobe is opening up, and it contains FlexUnit-based unit tests.
So, what am I looking for?
I'd like to be able to work on SchevoFlex, write tests for both the Python Side and the ActionScript side, run all of the tests at once using nose, and generally keep a fluid test-driven development cycle going... especially since part of the project is making sure we have rock-solid communications between the client and server!
Lazyweb? :)
Tags: actionscript, asunit, flex, flexunit, Python, Schevo, testing
Posted in Uncategorized | No Comments »
Wednesday, February 6th, 2008
I finally wanted to make hg view work.
When I downloaded a Mac OS X installer for Mercurial I noticed that the hgk extension (invoked by hg view) didn't work out of the box. No big deal right away.
Today I wanted to use it though!
Here's how to get it to work:
Download and install a new version of Mercurial using the link above.
Clone the Mercurial repository, then update it to the revision that you had just installed, and finally copy the hgk script to your personal bin directory:
$ hg clone http://selenic.com/hg hg-upstream
$ hg up -r b7f44f01a632
$ cp hg-upstream/contrib/hgk ~/bin
You could also copy it to your system-wide bin directory:
$ sudo cp hg-upstream/contrib/hgk /usr/local/bin
Edit your ~/.hgrc file to turn on the extension and point it to the location of your hgk script:
[extensions]
hgk=
[hgk]
path=/Users/myusername/bin/hgk
(If you copied it to your system-wide bin directory, use /usr/local/bin/hgk for the path value.)
Tags: mercurial, osx, Python
Posted in Uncategorized | 10 Comments »
Tuesday, January 22nd, 2008
... as I created Slipper last night.
Today, 0.1a1 came to fruition!
That was a lot of fun, and part of my geeky repository-as-documentation-website dreams have come true!
Tags: dvcs, mercurial, Python, slipper
Posted in Uncategorized | No Comments »
Friday, January 11th, 2008
I've fallen in love with Mercurial. It's used by projects and people that I respect, and I'm using it more and more.
I wanted to make sure I was using the latest version, but I didn't want to uninstall gutsy's version 0.9.4 and install it from source, nor did I want to upgrade my entire system to hardy. I've played around with such bleeding-edge things in the past, and while I still like to bleed sometimes, the Linux desktop is not one of those areas in which I desire to. :)
So, what to do?
Fortunately, it's easy to backport it from hardy. Here's what I did:
$ vim /etc/apt/sources.list
Add this line to the end:
deb-src http://us.archive.ubuntu.com/ubuntu/ \
hardy main restricted universe multiverse
Save and exit.
$ sudo apt-get update
$ sudo apt-get build-dep mercurial
$ fakeroot apt-get source -b mercurial
$ sudo dpkg -i mercurial_0.9.5-2_i386.deb
Lather, rinse, then repeat steps 4 through 7 as necessary if you're anxious. Or, just wait three months for hardy. :)
Tags: gutsy, hardy, installing, mercurial, Python, ubuntu, upgrading
Posted in Uncategorized | 6 Comments »
Monday, January 7th, 2008
I am using Mercurial to manage the source for some of my newer projects, and hg.setuptools caught my attention as something that would be very useful. I'm used to having the same functionality using Subversion, that is to say, I'm used to setuptools figuring out what files it should include with a distribution based on whether or not they're in the repository.
I use virtualenv to manage my development environments, and I found that when using hg.setuptools 0.2 out of the box, I'd get errors such as the following:
File "/var/lib/python-support/python2.5/mercurial/demandimport.py", line 70, in __call__
raise TypeError("'unloaded module' object is not callable")
TypeError: 'unloaded module' object is not callable
I ran across a note that mentioned disabling demandimport, so that is what I did with hg.setuptools. I uploaded a patch that made it work for me. If you're having the same problem, I hope it works for you too!
Tags: mercurial, patch, problem, Python, setuptools, solution, virtualenv
Posted in Uncategorized | No Comments »
Tuesday, December 11th, 2007
Do you find yourself keeping a Subversion tree for your project similar to this one?
http://myproject.com/svn/
branches/
featureful-23/
fancy-47/
tags/
trunk/
Do you find yourself checking out paths like this?
$ svn co http://myproject.com/svn/trunk/ MyProject
And then, do you find yourself switching to a branch in your MyProject directory, like so?
$ svn sw http://myproject.com/svn/branches/featureful-23
Do you ever find it tiring that you have to type that URL so much?
The Python script below might be useful for you then!
(more...)
Tags: practices, Programming, Python, subversion
Posted in Uncategorized | No Comments »